Is it possible to use VBA to control outlook to do things like look through a specific inbox folder and parse certain emails for say... email addresses and so on?
Is it possible to use VBA to control outlook to do things like look through a specific inbox folder and parse certain emails for say... email addresses and so on?
I do it a lot for automated imports of data, though I've always used the subject. This got me started:
http://www.thatlldoit.com/Pages/howtosarticles.aspx
Specifically the "Saving an Email Attachment" section.
Great that looks like it will search through subjects in an email and more so I can look for specific matching strings - this will make it possible to do what I want.I do it a lot for automated imports of data, though I've always used the subject. This got me started:
http://www.thatlldoit.com/Pages/howtosarticles.aspx
Specifically the "Saving an Email Attachment" section.
Any code I make I will post.
I'm thinking of putting the code on my website down the track so that it is organised just like the website you posted.
Thanks pbaldy
I do have another question however
I notice code online that uses ActiveExplorer()
I also noticed that the default folder inbox = 6 in the code but how would you refer to a custom made folder?
Where that code has outItem.Subject my guess is you might be able to test outItem.From for an email address, but that's total speculation.
I typically move emails to a subfolder of the inbox when I finish the import, and this is how I set that:
Set outTargetFolder = outFolder.Folders.Item("TravelocityTransactions")
I'm new to this so I'm not sure what I am doing wrongWhere that code has outItem.Subject my guess is you might be able to test outItem.From for an email address, but that's total speculation.
I typically move emails to a subfolder of the inbox when I finish the import, and this is how I set that:
Set outTargetFolder = outFolder.Folders.Item("TravelocityTransactions")
Currently I have
of course objEmail is null as I haven't selected anything or it where the selection is. Preferably I'd like it to find the specific folder and loop through all the emails in the folder...Code:Function getOutlookBounceBack(outSubject As String) Dim objOL As Outlook.Application 'Outlook.Application Dim outFolder As Object 'Outlook.Folder Dim outNameSpace As Object 'Outlook.NameSpace Dim objEmail As Outlook.MailItem Dim objSelection As Outlook.Selection outSubject = UCase(outSubject) Set objOLApp = CreateObject("Outlook.Application") Set outNameSpace = objOLApp.GetNamespace("MAPI") For Each objEmail In objSelection If objSelection.Subject = outSubject Then Debug.Print objSelection.Subject End If Next End Function
You didn't set outFolder, and you completely made up this line:
For Each objEmail In objSelection
which should be using outFolder. Also make sure you compare apples to apples case-wise.