PDA

View Full Version : Add message to all emails in my Outlook outbox



tactps
07-01-2010, 06:09 AM
Hi,:banghead:

I have about 100 emails in my outbox that have attachments and subject lines, but no message (mail merge from Word as attachment).

I would like to add an identical message to each of those emails before sending them.

Can you please give me the VBA syntax for this?

Outlook is clearly not my forte.:dunno

Thank you.
Anton

Crocus Crow
07-01-2010, 09:51 AM
This should help. Edit the body text as required, and I suggest you make Outlook work offline before you run this and then Send/Receive manually.
Public Sub ABT()

Dim olNs As Outlook.NameSpace
Dim olOutbox As Outlook.MAPIFolder
Dim olItem As Object
Dim olEmail As Outlook.MailItem

Set olNs = GetNamespace("MAPI")
Set olOutbox = olNs.GetDefaultFolder(olFolderOutbox)

For Each olItem In olOutbox.Items
If olItem.Class = olMail Then
Set olEmail = olItem
With olEmail
.Body = "New body text"
.Save
.Send
End With
End If
Next

End Sub

tactps
07-02-2010, 01:04 AM
You have made me very, very happy!

Works a treat.

Thanks:cloud9: