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
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