Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Outlook SenderName with VBA

Status
Not open for further replies.

mrgulic

Technical User
Sep 18, 2001
248
US
I am using VBA (MS Access) to automate parsing of emails in a mailbox. When I try to get the sender name (.SenderName) or (.SenderEmailAddress) I get that $%#%%& annoying "....is trying to access email address...." Outlook warning.

Code:
Set objOutlook = CreateObject("Outlook.Application")
Set objNS = objOutlook.GetNamespace("MAPI")
Set objActiveFolder = objNS.Folders("Outlook").Folders("Inbox")

On Error Resume Next
    For i = 1 To objActiveFolder.Items.Count
        Set objItem = objActiveFolder.Items(i)
        strFrom = objItem.SenderName
    Next i

I was using a linked table in Access to read the message info from the Inbox but the EntryID is not shown in the table. I need the EntryID to move the message to another folder. I was using the subject line to move items but some messages and times are exact.

I can't use any 3rd party add-in either.

Thanks in advance for any assistance.
 
Do a google search for outlook object model guard

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Try something like
variable=objActiveFolder.Items(i).entryid
instead of messing with the address, it may get past the security prompts
wjwjr

This old world keeps spinning round - It's a wonder tall trees ain't layin' down
 
white605

The problem is that I need the email address. There are messages that come from two specific addresses and i need to target those for processesing. Getting the EntryID or Subject Line is not a problem. The email address is the only one that causes the security problem.
 
Why not simply add some rules in outlook ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I could create a rule, but that is only one step in the parsing process. I have to know who of 2 address the email is from, what the subject line is and two seperate lines within the body.

Funny thing is that at work when i run it, the security warning does not appear, only when i am working on it at home. Same version of outlook, the only difference is work uses Exchange rather then POP.

Thanks for your time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top