using coms in Outlook to get specific body text
Posted: 29 Jan 2023, 23:03
I have a body of text in a file location. The body text has more information then i need.
Im wondering if its possible to loop through multiple emails in the folder that contains the subject "Please Prevent". Then filter out all information that is not the contain a string of numbers. so that if i were to put a msgbox it it would just diplay "56151_515151". Geting those numbers and adding them to an excel in colum A, along with the date the email was recived in colum B.
e.g
xxxxxxxxxxx
Order IDs: 56151_515151
xxxxxxxxxxx
xxxxxxxxxxx
xxxxxxxxxxx
Here is what i have thus far
Im wondering if its possible to loop through multiple emails in the folder that contains the subject "Please Prevent". Then filter out all information that is not the contain a string of numbers. so that if i were to put a msgbox it it would just diplay "56151_515151". Geting those numbers and adding them to an excel in colum A, along with the date the email was recived in colum B.
e.g
xxxxxxxxxxx
Order IDs: 56151_515151
xxxxxxxxxxx
xxxxxxxxxxx
xxxxxxxxxxx
Here is what i have thus far
Code: Select all
olApp := ComObjActive("Outlook.Application") ; Create or Active will work
olNameSpace := olApp.GetNamespace("MAPI")
olFolder := olApp.Session.Folders("bcable@Duncansolutions.net").Folders.Item("Inbox").Folders.Item("Returns").Folders.Item("PGA") ; Inbox Folder
Folders(olFolder)
Folders(olFolder)
{
for olItem in olFolder.Folders
{
for olItem in olFolder.Items
MsgBox % "`n" olItem.ReceivedTime "`n" olItem.Subject "`n" olItem.Body
Folders(olfolder)
}
}