![]() |
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, Hoping someone can help. I have absolutely no vba experience at all so am looking for a complete hand holding experience if possible!
I need to be able to set up an auto rule to trigger when a set e-mail arrives (I can do this bit) that uses a piece of script to extract an email address from the body of the email and fwd a message on to the extracted email. The email address in the body of the message will always be preceeded by Email Address : although there are a number of spaces between the end of address anf the colon but not sure if that matters for a script? Can anyone help? Outlook 2003 Thanks Annabel |
Ads |
#2
|
|||
|
|||
![]()
some further info that looks like it might effect how script works
the format of the email appears to contain tables the attachment e-mail2 is how the email looks, and email1 is how it copy and pastes into words with tables displayed |
#3
|
|||
|
|||
![]()
Ok with 7 hours of googling this is how far i've got - I'm stuck on the Split function (nr bottom) bit though as my email address line contains tabs and spaces and i can't find out how to tell it i only want the bit around the @
Sub plain(MyMail As MailItem) Dim strID As String Dim olNS As Outlook.NameSpace Dim olMail As Outlook.MailItem Dim emailtosend As String strID = MyMail.EntryID Set olNS = Application.GetNamespace("MAPI") Set olMail = olNS.GetItemFromID(strID) olMail.BodyFormat = olFormatPlain olMail.Save Set Msg = olNS.GetItemFromID(MyMail.EntryID) Msg.BodyFormat = olFormatPlain 'CALL THE SUB TO PARSE BODY TEXT AND GET THE EMAIL emailtosend = SearchBody(Msg.Body) If emailtosend “” Then Set NewForward = Msg.Forward With NewForward .Subject = Msg.Subject .To = emailtosend .Body = Msg.Body .Send End With With Msg .UnRead = False .FlagStatus = olNoFlag End With Else GoTo ExitProc End If ExitProc: Set NewForward = Nothing Set Msg = Nothing Set objItem = Nothing End Sub Function SearchBody(msgbody) As String lines = Split(msgbody, vbCrLf) '–GET THE EMAIL TO SEND TO For Each Line In lines If InStr(Line, "Email Address") Then parsed = Split(Line, ":") If InStr(parsed(1), "@") Then 'return the email address SearchBody = parsed(1) End If End If Next End Function Last edited by annabel : June 23rd 10 at 09:50 AM. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Insert Contact Mailing Address into the body of E-Mail | Bob Raney | Outlook - Using Contacts | 1 | November 7th 09 12:47 AM |
copying e-mail addresses (display names) from body of e-mail | jpampinella | Outlook - Using Contacts | 2 | February 26th 07 09:40 PM |
outlook 2k3 Script: how to Save Mail body to txt file | news.microsoft.com | Outlook and VBA | 5 | November 7th 06 03:23 PM |
e-mail backspace deleting in body instead of in address field | [email protected] | Outlook - General Queries | 0 | October 18th 06 09:48 AM |
Script to forward e-mail to address in Subject line | [email protected] | Outlook and VBA | 2 | September 7th 06 02:45 PM |