I want to save attachments in my Inbox from a specific sender to a folder I:\Securities\Cash Commitments & Projection\attachment name_date.xls. I have this code in VBA outlook that I lifted from an example, but I can't figure out what to change to make it sender-specific.
Public Sub Application_Startup()
Dim MItem As MailItem
Dim oAttachment As Attachment
Dim sSaveFolder As String
Dim oDefInbox As Folder
Dim targetFolder As Folder
Dim myItems As Outlook.Items
Dim Item As Object
Set oDefInbox = Session.GetDefaultFolder(olFolderInbox)
Set targetFolder = Session.GetDefaultFolder(olFolderInbox)
sSaveFolder = "I:\Securities\Cash Commitments & Projection"
For Each MItem In targetFolder.Items
If MItem.UnRead = True Then
For Each oAttachment In MItem.Attachments
oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
Set oAttachment = Nothing
Next oAttachment
MItem.UnRead = False
End If
Next
End Sub
Public Sub Application_Startup()
Dim MItem As MailItem
Dim oAttachment As Attachment
Dim sSaveFolder As String
Dim oDefInbox As Folder
Dim targetFolder As Folder
Dim myItems As Outlook.Items
Dim Item As Object
Set oDefInbox = Session.GetDefaultFolder(olFolderInbox)
Set targetFolder = Session.GetDefaultFolder(olFolderInbox)
sSaveFolder = "I:\Securities\Cash Commitments & Projection"
For Each MItem In targetFolder.Items
If MItem.UnRead = True Then
For Each oAttachment In MItem.Attachments
oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
Set oAttachment = Nothing
Next oAttachment
MItem.UnRead = False
End If
Next
End Sub