Link to home
Start Free TrialLog in
Avatar of Nirvana
NirvanaFlag for India

asked on

code to save all attachments in outlook with specific subject

How do i save all the attachments from outlook 2010 which has the words "invoice orders" in the subject line. the attachments have to be saved to a specific folder in a new folder have to be created by date in "D" drive and save all the attachments.
Avatar of Najam Uddin
Najam Uddin
Flag of United States of America image

bare save logic
Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
    If itm.Subject = "your string" Then
        Dim objAtt As Outlook.Attachment
        Dim saveFolder As String
        Set saveFolder = "c:\temp\"
        For Each objAtt In itm.Attachments
            objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
            Set objAtt = Nothing
        Next
     End If
     
End Sub

Open in new window


Call this function on the event you want to process.
ASKER CERTIFIED SOLUTION
Avatar of Nirvana
Nirvana
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nirvana

ASKER

Thank you very much