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

extract email from message body



 
 
Thread Tools Search this Thread Display Modes
  #11  
Old April 30th 07, 06:44 PM posted to microsoft.public.outlook.program_vba
ed
external usenet poster
 
Posts: 114
Default extract email from message body

I tried this:


Instr ("urn:schemas:httpmail:textdescription, " %@% ",

vbTextCompare )

But it only returns an index of the found text.

Can you describe a regular expression that would work?



"Sue Mosher [MVP-Outlook]" wrote:

Or use regular expressions.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Michael Bauer [MVP - Outlook]" wrote in message ...


You can search the addresses with the Instr function. If there's no specific
position for an address then search for the @ character, then for the
following ' ', and with InstrRev for the leading ' '. Knowing that both
position, you can then extract the string with the Mid function.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Quick-Cats - Categorize Outlook data:
http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6

Am Wed, 25 Apr 2007 19:00:02 -0700 schrieb Edward:

Can anyone suggest the best way to open each file in an OUtlook

subdirectory
and extract an email address from the body of the email? I have mail

coming
back as undeliverable, and want to prune those addresses from our lists,

but
the address to which the email was sent is not the same as the return
address, which is usually an automated responder from a mail server that
can't find the address in to:

Basically, I'm trying to write code that will say:
go to the undeliverables subdirectory in Outlook;
for each email, check the body of the email for any/all email address(es)
append the email address to a text file;


Ads
  #12  
Old April 30th 07, 06:44 PM posted to microsoft.public.outlook.program_vba
ed
external usenet poster
 
Posts: 114
Default extract email from message body

This function only returns a numerical value designating the position of the
beginning of the search string. It doesn't return the search string itself.
Also, unable to use 'like' operator in it, so can't get it to do the search.



"Michael Bauer [MVP - Outlook]" wrote:



You can search the addresses with the Instr function. If there's no specific
position for an address then search for the @ character, then for the
following ' ', and with InstrRev for the leading ' '. Knowing that both
position, you can then extract the string with the Mid function.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Quick-Cats - Categorize Outlook data:
http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6

Am Wed, 25 Apr 2007 19:00:02 -0700 schrieb Edward:

Can anyone suggest the best way to open each file in an OUtlook

subdirectory
and extract an email address from the body of the email? I have mail

coming
back as undeliverable, and want to prune those addresses from our lists,

but
the address to which the email was sent is not the same as the return
address, which is usually an automated responder from a mail server that
can't find the address in to:

Basically, I'm trying to write code that will say:
go to the undeliverables subdirectory in Outlook;
for each email, check the body of the email for any/all email address(es)
append the email address to a text file;


  #13  
Old April 30th 07, 06:46 PM posted to microsoft.public.outlook.program_vba
ed
external usenet poster
 
Posts: 114
Default extract email from message body



"Sue Mosher [MVP-Outlook]" wrote:

Or use regular expressions.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Michael Bauer [MVP - Outlook]" wrote in message ...


You can search the addresses with the Instr function. If there's no specific
position for an address then search for the @ character, then for the
following ' ', and with InstrRev for the leading ' '. Knowing that both
position, you can then extract the string with the Mid function.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Quick-Cats - Categorize Outlook data:
http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6

Am Wed, 25 Apr 2007 19:00:02 -0700 schrieb Edward:

Can anyone suggest the best way to open each file in an OUtlook

subdirectory
and extract an email address from the body of the email? I have mail

coming
back as undeliverable, and want to prune those addresses from our lists,

but
the address to which the email was sent is not the same as the return
address, which is usually an automated responder from a mail server that
can't find the address in to:

Basically, I'm trying to write code that will say:
go to the undeliverables subdirectory in Outlook;
for each email, check the body of the email for any/all email address(es)
append the email address to a text file;

Havent seen your book at the stores, but will go to Amazon for it!

  #14  
Old April 30th 07, 06:50 PM posted to microsoft.public.outlook.program_vba
ed
external usenet poster
 
Posts: 114
Default extract email from message body

I'm not trying to search the address line; I'm trying to search the body of
the email for an embedded address. I'm trying to search for a string ""*@*""
within the body of the identified email. I need to know how to tell Outlook
to look at the body of the selected email.

I think the ccode is something like this:

Instr ("urn:schemas:httpmail:textdescription, " %@% ",

vbTextCompare )

Does that look like it would address the body of the selected email for the
search string?

"Ed" wrote:

I can't seem to address the body of the email. I have a routine that cycles
through the index of the Inbox, but am unsure how to actually address the
body of the email. Is it an Item, a message, a body, a PR_body, etc. Can't
seem to address it.

Also, I have a search string, " *@* ", which should work if I can find the
right way to run the body through it. However, the like operator doesn't work
in the AdvancedSearch function.

"Michael Bauer [MVP - Outlook]" wrote:



You can search the addresses with the Instr function. If there's no specific
position for an address then search for the @ character, then for the
following ' ', and with InstrRev for the leading ' '. Knowing that both
position, you can then extract the string with the Mid function.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Quick-Cats - Categorize Outlook data:
http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6

Am Wed, 25 Apr 2007 19:00:02 -0700 schrieb Edward:

Can anyone suggest the best way to open each file in an OUtlook

subdirectory
and extract an email address from the body of the email? I have mail

coming
back as undeliverable, and want to prune those addresses from our lists,

but
the address to which the email was sent is not the same as the return
address, which is usually an automated responder from a mail server that
can't find the address in to:

Basically, I'm trying to write code that will say:
go to the undeliverables subdirectory in Outlook;
for each email, check the body of the email for any/all email address(es)
append the email address to a text file;


  #15  
Old April 30th 07, 06:56 PM posted to microsoft.public.outlook.program_vba
ed
external usenet poster
 
Posts: 114
Default extract email from message body

I tried this:


Dim objSch As Search
Const strF As String = "urn:schemas:httpmail:textdescription LIKE
'"urn:schemas:httpmail:textdescription LIKE ' *@* '
Const strS As String = "Inbox"
Const strTag As String = "GotAddress"
Set objSch = Application.AdvancedSearch(Scope:=strS, _
Filter:=strF, Tag:=strTag)

Call writer
End Sub

Public Function writer()

Dim objRsts As Results

Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("c:\UndelResults.txt", True)

MsgBox "The search " & objSch.Tag & "has completed."
Set objRsts = objSch.Results
'Display number in Results collection
MsgBox "There are " & objRsts.Count & "address items"
'Write each member of Results to file
For Each Item In objRsts
a.writeline (Item) 'took this out: objRsts.WriteLine Item
'this hasn't been set up yet because
'writeline doesn't point to a file
MsgBox "The writer ran"
Next
a.Close

Didn't work. Any suggestions? Maybe I just wrote it wrong. Can you tell if
the search string is correctly formatted: do the spaces need " around them,
or just spaces? Is & needed between search characters? Your help much
appreciated.


"Michael Bauer [MVP - Outlook]" wrote:



You can search the addresses with the Instr function. If there's no specific
position for an address then search for the @ character, then for the
following ' ', and with InstrRev for the leading ' '. Knowing that both
position, you can then extract the string with the Mid function.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Quick-Cats - Categorize Outlook data:
http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6

Am Wed, 25 Apr 2007 19:00:02 -0700 schrieb Edward:

Can anyone suggest the best way to open each file in an OUtlook

subdirectory
and extract an email address from the body of the email? I have mail

coming
back as undeliverable, and want to prune those addresses from our lists,

but
the address to which the email was sent is not the same as the return
address, which is usually an automated responder from a mail server that
can't find the address in to:

Basically, I'm trying to write code that will say:
go to the undeliverables subdirectory in Outlook;
for each email, check the body of the email for any/all email address(es)
append the email address to a text file;


  #16  
Old May 1st 07, 01:48 AM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default extract email from message body

MSDN has good articles on using on regular expressions.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Ed" wrote in message ...
I tried this:


Instr ("urn:schemas:httpmail:textdescription, " %@% ",

vbTextCompare )

But it only returns an index of the found text.

Can you describe a regular expression that would work?



"Sue Mosher [MVP-Outlook]" wrote:

Or use regular expressions.



"Michael Bauer [MVP - Outlook]" wrote in message ...


You can search the addresses with the Instr function. If there's no specific
position for an address then search for the @ character, then for the
following ' ', and with InstrRev for the leading ' '. Knowing that both
position, you can then extract the string with the Mid function.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Quick-Cats - Categorize Outlook data:
http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6

Am Wed, 25 Apr 2007 19:00:02 -0700 schrieb Edward:

Can anyone suggest the best way to open each file in an OUtlook
subdirectory
and extract an email address from the body of the email? I have mail
coming
back as undeliverable, and want to prune those addresses from our lists,
but
the address to which the email was sent is not the same as the return
address, which is usually an automated responder from a mail server that
can't find the address in to:

Basically, I'm trying to write code that will say:
go to the undeliverables subdirectory in Outlook;
for each email, check the body of the email for any/all email address(es)
append the email address to a text file;


  #17  
Old May 1st 07, 07:50 PM posted to microsoft.public.outlook.program_vba
ed
external usenet poster
 
Posts: 114
Default extract email from message body

Any idea why this snippet wouldn't work:
dim address as string
address = myItem."urn:schemas:httpmail:textdescription"
address = InStr("myMsg", " *@* ", compare)
AdrOut = address.Text

Does inStr need a different syntax?

This doesn't work either:

Do While n filecount 'myFolder.Index.Count
Set myItem = myFolder.Items(n)
Set myMsg = (myItem.urn:schemas:httpmail:textdescription)
'Call SearchInboxFolder
'address = myItem."urn:schemas:httpmail:textdescription"
address = InStr("myMsg", " *@* ", compare)
AdrOut = address.Text


"Edward" wrote:

Can anyone suggest the best way to open each file in an OUtlook subdirectory
and extract an email address from the body of the email? I have mail coming
back as undeliverable, and want to prune those addresses from our lists, but
the address to which the email was sent is not the same as the return
address, which is usually an automated responder from a mail server that
can't find the address in to:

Basically, I'm trying to write code that will say:
go to the undeliverables subdirectory in Outlook;
for each email, check the body of the email for any/all email address(es)
append the email address to a text file;

--
Phantom Researcher

  #18  
Old May 3rd 07, 06:12 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default extract email from message body


Say, MyItem is a variable for an MailItem - then MyItem.Body contains the
plain body of that item, MyItem.HTMLBody contains the html formatted body.

The other syntax ("urn:schemas:httpmail:textdescription") is necessary only
if you want to use the AdvancedSearch method. After calling that method you
get the result in the AdvancedSearchComplete event:

Sub TestAdvancedSearchComplete()
Dim strF As String
Dim strS As String: strS = "Posteingang"

strF = "urn:schemas:httpmail:textdescription LIKE '%VBOffice%'"

Application.AdvancedSearch(strS, strF)
End Sub

Private Sub Application_AdvancedSearchComplete(ByVal SearchObject As
Outlook.Search)
Debug.Print Found: " & SearchObject.Results.Count
End Sub

You can easily explore all of the properties of an object by using the
object browser (f2); switch from All Libraries to Outlook.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Quick-Cats - Categorize Outlook data:
http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6


Am Tue, 1 May 2007 11:50:00 -0700 schrieb Ed:

Any idea why this snippet wouldn't work:
dim address as string
address = myItem."urn:schemas:httpmail:textdescription"
address = InStr("myMsg", " *@* ", compare)
AdrOut = address.Text

Does inStr need a different syntax?

This doesn't work either:

Do While n filecount 'myFolder.Index.Count
Set myItem = myFolder.Items(n)
Set myMsg = (myItem.urn:schemas:httpmail:textdescription)
'Call SearchInboxFolder
'address = myItem."urn:schemas:httpmail:textdescription"
address = InStr("myMsg", " *@* ", compare)
AdrOut = address.Text


"Edward" wrote:

Can anyone suggest the best way to open each file in an OUtlook

subdirectory
and extract an email address from the body of the email? I have mail

coming
back as undeliverable, and want to prune those addresses from our lists,

but
the address to which the email was sent is not the same as the return
address, which is usually an automated responder from a mail server that
can't find the address in to:

Basically, I'm trying to write code that will say:
go to the undeliverables subdirectory in Outlook;
for each email, check the body of the email for any/all email address(es)
append the email address to a text file;

--
Phantom Researcher

  #19  
Old May 3rd 07, 04:13 PM posted to microsoft.public.outlook.program_vba
Morris
external usenet poster
 
Posts: 2
Default extract email from message body

Links for regularExpressions a

http://support.microsoft.com/default...02&Product=vbb

http://msdn.microsoft.com/library/de...63906a7353.asp

bestfriends in doing magic with patterns

  #20  
Old May 3rd 07, 06:26 PM posted to microsoft.public.outlook.program_vba
ed
external usenet poster
 
Posts: 114
Default extract email from message body

I cannot figure out how to 'read' the body text string. I have the search
text, and am able to address the mapi folder. Can't get InStr to work; it
returns a boolean.

"Michael Bauer [MVP - Outlook]" wrote:



You can search the addresses with the Instr function. If there's no specific
position for an address then search for the @ character, then for the
following ' ', and with InstrRev for the leading ' '. Knowing that both
position, you can then extract the string with the Mid function.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Quick-Cats - Categorize Outlook data:
http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6

Am Wed, 25 Apr 2007 19:00:02 -0700 schrieb Edward:

Can anyone suggest the best way to open each file in an OUtlook

subdirectory
and extract an email address from the body of the email? I have mail

coming
back as undeliverable, and want to prune those addresses from our lists,

but
the address to which the email was sent is not the same as the return
address, which is usually an automated responder from a mail server that
can't find the address in to:

Basically, I'm trying to write code that will say:
go to the undeliverables subdirectory in Outlook;
for each email, check the body of the email for any/all email address(es)
append the email address to a text file;


 




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
How do I modify the message body displayed in the email window? Steffen Heinzl Add-ins for Outlook 4 November 10th 06 10:49 AM
Email font size in body changes randomly after the message is sent [email protected] Outlook - General Queries 0 May 31st 06 10:52 PM
Help: Send To Email Message in Body TJ Outlook Express 3 May 4th 06 01:23 PM
Attachment does not show on header but in message body when create new email Johnny Chow Outlook - General Queries 2 January 30th 06 11:47 PM
How to filter email with blank subject, to, and message body ken4az Outlook - Installation 0 January 20th 06 06:27 PM


All times are GMT +1. The time now is 09:50 AM.


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