|
Question : auto-save outlook email attachment within SSIS
|
|
Hi!
I'd like to do the following within a scheduled SSIS package:
1. Search for and auto-save a specific (via subject line) Outlook 2003 email attachment to hard drive 2. Move the email to a different outlook folder (i.e. called ProcessedFiles)
Would someone be able to 1,2,3 an explanation with code that would be able to do this?
|
|
Answer : auto-save outlook email attachment within SSIS
|
|
1. This will check for the attachments and will save the attachments
Sub SaveAttachments() Dim myOlapp As Outlook.Application Dim myNameSpace As Outlook.NameSpace Dim myFolder As Outlook.MAPIFolder Dim myItem As Outlook.MailItem Dim myAttachment As Outlook.Attachment Set myOlapp = CreateObject("Outlook.Application") Set myNameSpace = myOlapp.GetNamespace("MAPI") Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox) For Each myItem In myFolder.Items If myItem.Attachments.Count <> 0 Then For Each myAttachment In myItem.Attachments myAttachment.SaveAsFile "C:\MailTest\" & myAttachment.FileName Next End If Next End Sub
|
|
|