How do I extract the email adress from this text string?

dcharland

New Member
Joined
Mar 2, 2011
Messages
40
Hello,

I'm writing some code to extract an email address, so far I was able to separate the body of the email into individual line. But would need some guidance with how to extract the email (if one is found in the string). In some other instances the email will be in the "from" field, but I'm assuming that the code will be re-usable?

The string would look something like this:
HTML:
  Your message did not reach some or all of the intended recipients.
   
        Subject:    Information Meeting - Networking for Career Opportunity
        Sent: 07/03/2011 11:43 AM
   
  The following recipient(s) cannot be reached:
   
        'csdi@chaumontsystems.com' on 07/03/2011 11:46 AM
              550 5.3.4 Requested action not taken; To continue sending messages, please sign in to your account.
And here is the code I have so far:

HTML:
For Each MItem In MySubFolder.Items
'MsgBox Ebody
If Left(MItem.Subject, 13) = "Undeliverable" Then ' If the first 14 characters from the subject are "Undeliverable"
Status = "Undeliverable"
Ebody = Split(MItem.body, vbLf)
X = 0 'each line in the body was split, this x will loop through the Ebody sub-strings
' look for email in each sub-string
'*** This is where I have no ideas ******
Thanks
 
Thanks AlphaFrog for the code review, learned a lot from it and now working at implementing the changes into my original code.

Denis
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,214,971
Messages
6,122,520
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top