View Single Post
  #1  
Old June 20th 07, 12:03 PM posted to microsoft.public.outlook.program_vba
bony_tony
external usenet poster
 
Posts: 5
Default Attach documents to mail merged emails based on merge fields

Hi,
I'm new to VBA in outlook, although I have used it in Excel

I have read this thread;

http://groups.google.co.uk/group/mic...7f64afc62bd773

I now have emails in my outbox, which I would like to attach files to.

However, I want to attach different Excel files to the different
messages, depending on which account reference (insterted from a merge
field) the message is relating to.
It looks like the merge fields have been replaced with text on the
emails, so I would somehow like to attach different files to the
emails based on the references found after "Account " on the first
line;

ie I would like to attach, say C:/REF12345.xls to the first message,
which would have the following in it's body

Account REF12345

Balance 13,024.88

Regards
A Company

The account reference is sometimes a different length of characters.

I'm assuming the following code would do this, but how do I apply my
reference to the value 'x'?

Sub AddAttachmentToSelectedMessages()
Dim objItem As Object
If ActiveExplorer.Selection.Count = 0 Then Exit Sub

For Each objItem In ActiveExplorer.Selection
objItem.Attachments.Add ("C:\" & x & ".xls")
objItem.Save
objItem.Send
Next
End Sub

Regards
Tony

Ads
 

Secured Loans - Debt Consolidation - Free Music Download - Free Advertising - Credit Cards