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 |
#21
|
|||
|
|||
extract email from message body
Tried InStr and AdvancedSearch. the latter requries a whole second routine
to catch the results of the search, but I'm not sure it is capable of capturing from a MAPI file. This works, but I can't figure out how to capture the result: Dim objSch As Search Const strF As String = "urn:schemas:httpmail:textdescription LIKE '%'" Const strS As String = "undeliverables" Const strTag As String = "GITem" Set objSch = Application.AdvancedSearch(Scope:=strS, _ Filter:=strF, Tag:=strTag) I cannot figure out how to get the InStr function to return anything but a boolean (false). sorry if I confused some terminology. "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 |
Ads |
#22
|
|||
|
|||
extract email from message body
Why don't you try the sample for AdvancedSearch that I gave you with my last post? Your code doesn't work, that's right. if you prefer to loop through all of the items and search with Instr: That function returns the postion of the found string - if any. Then you must use the Left and/or Right functions to get the string left and/or right side from that position. As it's hard to follow the thread you messed up totally, here's a sample for a loop in *principle*: Dim obj as Object Dim Items as Outlook.Items Dim Folder as Outlook.Mapifolder Dim i as Long Dim Pos1 as Long,Pos2 as Long Dim SLeft as String, SMiddle as String, SRight As String Set Folder=Application.Session.GetDefaultFolder(olFold erInbox) Set Items=Folder.Items For i=1 to Items.Count Set obj=Items(i) Pos1= Instr(1,obj.Body,"whatever",vbTextCompare) If Pos10 Then ' "whatever" is found Pos2=pos1+Len("whatever") ' get the text left hand from the searched phrase SLeft = Left$(obj.Body,Pos1-1) ' get the text right hand from the searched phrase SRight = Mid$(obj.Body,Pos2+1) ' get the text searched phrase itself SMiddle = Mid$(obj.Body,Pos1,Pos2+1-Pos1) Endif Next -- 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 Thu, 3 May 2007 18:01:01 -0700 schrieb Ed: Tried InStr and AdvancedSearch. the latter requries a whole second routine to catch the results of the search, but I'm not sure it is capable of capturing from a MAPI file. This works, but I can't figure out how to capture the result: Dim objSch As Search Const strF As String = "urn:schemas:httpmail:textdescription LIKE '%'" Const strS As String = "undeliverables" Const strTag As String = "GITem" Set objSch = Application.AdvancedSearch(Scope:=strS, _ Filter:=strF, Tag:=strTag) I cannot figure out how to get the InStr function to return anything but a boolean (false). sorry if I confused some terminology. "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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
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 |