get information from outlook to excel
How can I:
flag an e-mail using a rule in outlook
from excel look for those flags
when found copy the text of the e-mail into excel and process it
then change the flag to completed
look for the next flag
if none quit outlook
I've tried several samples of code and so far I can't seem to open outlook from excel.
Thanks
Re: get information from outlook to excel
the reading of the BODY of the email will cause a security popup that makes the user
allow it to interact with outlook....(im using outlook 2003)
just put this in a module in excel and add a reference to the outlook x.0 object library
VB Code:
Private Sub GetMail()
Dim OTL As New Outlook.Application
Dim MAPI As Outlook.Namespace
Dim INBOX As Outlook.MAPIFolder
Dim MAIL As Outlook.MailItem
Set MAPI = OTL.GetNamespace("MAPI")
Set INBOX = MAPI.GetDefaultFolder(olFolderInbox)
For Each MAIL In INBOX.Items
If MAIL.FlagIcon = olRedFlagIcon Then
Debug.Print MAIL.Subject 'this will work without causing security popup
Debug.Print MAIL.Body 'this WILL cause the security popup
End If
Next
Set MAIL = Nothing
Set INBOX = Nothing
Set Map = Nothing
Set OTL = Nothing
End Sub
Re: get information from outlook to excel
You also need to add a reference to MS Outlook xx.0 Object Library from Excels Project > References menu item.
I also have many many Outlook code examples on the forums. ;)