![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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 |
#2
|
|||
|
|||
![]()
It's ok, don't worry, found a function some outlook genius posted ;-)
Function ParseTextLinePair(strSource As String, strLabel As String) Dim intLocLabel As Integer Dim intLocCRLF As Integer Dim intLenLabel As Integer Dim strText As String ' locate the label in the source text intLocLabel = InStr(strSource, strLabel) intLenLabel = Len(strLabel) If intLocLabel 0 Then intLocCRLF = InStr(intLocLabel, strSource, vbCrLf) If intLocCRLF 0 Then intLocLabel = intLocLabel + intLenLabel strText = Mid(strSource, _ intLocLabel, _ intLocCRLF - intLocLabel) Else intLocLabel = Mid(strSource, intLocLabel + intLenLabel) End If End If ParseTextLinePair = Trim(strText) End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mail Merge User-Defined Fields | David E | Outlook - Using Forms | 4 | October 5th 06 12:07 AM |
How to direct output from Word mail merge to multiple Word documents | [email protected] | Outlook - General Queries | 3 | August 11th 06 05:10 AM |
Attach Mail Merge Letter to Contacts | Patti | Outlook - Using Contacts | 1 | July 29th 06 12:41 AM |
Mail Merge from Outlook opens up two MS Word documents. | [email protected] | Outlook - General Queries | 10 | July 6th 06 10:44 PM |
re. Can't attach photos or Word documents to email | mike carrington | Outlook - General Queries | 3 | May 3rd 06 05:05 PM |