A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

script for getting e-mail address from body to fwd e-mail



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 22nd 10, 01:58 PM
annabel annabel is offline
Junior Member
 
First recorded activity at Outlookbanter: Jun 2010
Posts: 3
Default script for getting e-mail address from body to fwd e-mail

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  
Old June 22nd 10, 04:22 PM
annabel annabel is offline
Junior Member
 
First recorded activity at Outlookbanter: Jun 2010
Posts: 3
Default

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
Attached Images
File Type: jpg email2.JPG (11.4 KB, 1 views)
File Type: jpg email1.JPG (12.6 KB, 0 views)
  #3  
Old June 22nd 10, 09:22 PM
annabel annabel is offline
Junior Member
 
First recorded activity at Outlookbanter: Jun 2010
Posts: 3
Default

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 04:36 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.