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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sender name vba outlook

Status
Not open for further replies.

msstrang

Programmer
Sep 19, 2005
62
US
excuse the messy code below, i'm still in the process of cleaning it up.
i'm trying to use MAPI or some other way to get the sender address from the email i am reading. the code below finds new mail in my inbox and saves the attachments and prints the email. all i need is to check for the sender name, but i get the security warning that outlook generates. could anyone give me a push in the right direction? i've looked all over the internet and am having trouble.

Sub NEWMAILATTACHMENTS()
Dim newMsg As Integer


Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)

c = myFolder.Items.Count


Do While Not x = c
x = x + 1
Set myitem = myFolder.Items(x)
Set myAttachments = myitem.Attachments

If myitem.UnRead = False Then GoTo notnew
'******If myitem.SenderName = "WFC_ENG/LIAO" Then*****security warning comes because i'm using vba to get the sender name.


myitem.PrintOut
numattachments = myAttachments.Count
myitem.Display


Set myitem = myOlApp.ActiveInspector.CurrentItem
Set myAttachments = myitem.Attachments

Do While Not numattachments = 0
myAttachments.Item(numattachments).SaveAsFile "I:\AutocadData\Temp\" & myAttachments.Item(numattachments).DisplayName
numattachments = numattachments - 1
Loop


myitem.Close olDiscard

'End If
'Next newMsg
notnew:
Loop

End Sub


 
Do a google search for outlook object model guard

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top