Download All Attachment from outlook Mails :

You can use this code to Download all Attachments in a specific folder from outlook mail.
Sub SaveAttachment(StrPath As String)
    Dim outLookApp       As Object
    Dim ObjMitem         As Object
    Dim NameSpace        As Object
    Dim ObjFolder        As Object
    Dim ObjAttachment    As Object
    Dim lngCounter       As Long
    lngCounter = 1
    Set outLookApp = CreateObject(“Outlook.Application”)
    Set NameSpace = outLookApp.GetNamespace(“MAPI”)
    Set ObjFolder = NameSpace.GetDefaultFolder(olFolderInbox).Folders(1)
    For Each ObjMitem In ObjFolder.Items
        If ObjMitem.Attachments.Count > 0 Then
        For Each ObjAttachment In ObjMitem.Attachments
            ObjAttachment.SaveAsFile StrPath & ObjAttachment.DisplayName
            Application.StatusBar = “Saving Attachment : ” & lngCounter
            lngCounter = lngCounter + 1
        End If
    Set outLookApp = Nothing
    Set ObjMitem = Nothing
    Set NameSpace = Nothing
    Set ObjFolder = Nothing
    Set ObjAttachment = Nothing
End Sub

2 Comments Add yours

  1. Gagan says:

    it isn’t working!! pls advice if I need to amend the above code?

  2. In the below line

    Set ObjFolder = NameSpace.GetDefaultFolder(olFolderInbox).Folders(1)

    you must select there folder like Inbox , sent item and others. from which you want to download the attachement

    Thanks for your comment
    Rajan verma

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s