Download & Move Attachments

Not open for further replies.


Outlook version
Outlook 2013 32 bit
Email Account

With this script i am already downloading and saving the particular files to my hard drive, now i have some more attachment to be downloaded but i want them to be saved to different folder on my hard drive, Help me to do this which will ease my work of moving files from one place to another. File name is COJ12991 to D:\Soft

Sub GetAttachments_From_Inbox()   
   On Error GoTo GetAttachments_err
   Dim appOl As New Outlook.Application
   Dim ns As Outlook.NameSpace
   Dim Inbox As Outlook.MAPIFolder
   Dim myDestFolder As Outlook.MAPIFolder
   Dim Item As Object
   Dim Atmt As Outlook.Attachment
   Dim FileName As String
   Dim i As Integer
   Dim iLoop As Integer
   Dim sender As String
   Dim bankName As String
   Dim ext As String
   Dim Items As Outlook.Items
   Dim oc As Object
   Dim moveEmail As Boolean
   Set ns = appOl.GetNamespace("MAPI")
   Set Inbox = ns.GetDefaultFolder(olFolderInbox)
   Set Item = Inbox.Items
   Set myDestFolder = Inbox.Folders("Personal Mail")
   i = 0
   iLoop = 0
   If Inbox.Items.Count = 0 Then 
'       ' MsgBox "There are no messages in the Inbox.", vbInformation, _
       "Nothing Found"
       Exit Sub
   End If
   For iLoop = 1 To Inbox.Items.Count
       For Each Item In Inbox.Items
           moveEmail = False
           For Each Atmt In Item.Attachments
                If UCase(Atmt.FileName) Like "Export*" Or _
               UCase(Atmt.FileName) Like "Report*" Or _
               UCase(Atmt.FileName) Like "Update" Or _
               UCase(Atmt.FileName) Like "Sales*" Or _
        FileName = "D:\Attachments\" & Atmt.FileName
                   Atmt.SaveAsFile FileName
                   moveEmail = True
                   i = i + 1
               End If
           Next Atmt
           If moveEmail Then
               Item.Move myDestFolder
           End If
       Next Item
       iLoop = iLoop + 1
        If i > 0 Then
       'MsgBox "I found " & i & " attached files." _
       & vbCrLf & "I have saved them into the D:\Attachments folder." _
       & vbCrLf & vbCrLf & "Have a nice day.", vbInformation, "Finished!"
      ' MsgBox "I didn't find any attached files in your mail.", vbInformation, "Finished!"
   End If 
   Set Atmt = Nothing
   Set Item = Nothing
   Set ns = Nothing
   Set appOl = Nothing
   Exit Sub 
   'MsgBox "An unexpected error has occurred." _
   & vbCrLf & "Please note and report the following information." _
   & vbCrLf & "Macro Name: GetAttachments" _
   & vbCrLf & "Error Number: " & Err.Number _
   & vbCrLf & "Error Description: " & Err.Description _
   , vbCritical, "Error!"
   Resume GetAttachments_exit 
End Sub
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
K Outlook Office 365 VBA download attachment Outlook VBA and Custom Forms 2
GregS Outlook 2016 iPhone won't download Outlook 2016 Mail. Using Outlook 0
O Office 365 Outlook - mark to download Using Outlook 0
G Download pdf attachments only if email subject has one of words Outlook VBA and Custom Forms 8
K Outlook 2010 duplicate download emails 1 inbox 1 PST no updates Using Outlook 3
R Would creating a new profile cause Outlook to download all the old mails from the server? Using Outlook 1
M Macro for attachments download adjustment Outlook VBA and Custom Forms 3
S Outlook 2013 doesn't download html messages Using Outlook 0
M Google Apps Mail *SENT* from iPhone doesn't download to Outlook via POP3 Using Outlook 1
P Email Download Outlook VBA and Custom Forms 12
C bcm 2010 download does not recognize outlook Using Outlook 3
RBLampert Outlook downloads error out if one particular account is the first to download Using Outlook 0
B Automatic picture download and changing email addresses Using Outlook 3
rezazy Do not download old email Using Outlook 1
D How to force full message download for all Gmail messages in all folders with IMAP in Outlook 2013 Using Outlook 1
V IMAP - download headers only Using Outlook 4
D VBA script to auto download attachments and rename file according to subject line Outlook VBA and Custom Forms 23
G Outlook 2013 won't download images Using Outlook 6
L Download/export multiple POP accounts Using Outlook 1
A Outlook doesnt download emails after reinstalling Using Outlook 4
T Unable to download e-mail sub account in OL 2010. No probs with Mailwasher Using Outlook 6
R Outlook download will not complete. Using Outlook 1
R Outlook Connector will not download ALL messages from hotmail accounts Using accounts in Outlook 4
S Outlook doesn't download all hotmail emails on Vista Using Outlook 2
K Download emails to HD Using Outlook 1
N Configure Outlook 2010 to download sent emails Using Outlook 4
Forum Admin Download BCM 2010 BCM (Business Contact Manager) 0
D Is It Possible To Download Contact Mngr Via a Website? BCM (Business Contact Manager) 1
P Download BCM Database BCM (Business Contact Manager) 1
R Auto Download Document Outlook VBA and Custom Forms 2
P How Do I Download Business Contact Manager BCM (Business Contact Manager) 1
P Download for KB957324 BCM (Business Contact Manager) 13
C Code to move mail with certain attachment name? Does Not work Outlook VBA and Custom Forms 3
B Move emails from one account to another Outlook VBA and Custom Forms 2
J Quick steps delete original email and move reply/sent email to folder Using Outlook 2
N How to add or delete items to Move dropdown Menu Using Outlook 0
Commodore Unable to move message Using Outlook 3
N Line to move origEmail to subfolder within a reply macro Outlook VBA and Custom Forms 0
C Move or copy from field to field Outlook VBA and Custom Forms 0
T Outlook 365 Move newly created tasks automatically on save. Outlook VBA and Custom Forms 1
NVDon Create new Move To Folder list Outlook VBA and Custom Forms 0
P Print attachments automatically and move the mail to an existing folder called "Ted" Outlook VBA and Custom Forms 4
T Macro to move reply and original message to folder Outlook VBA and Custom Forms 6
F VBA to move email from Non Default folder to Sub folders as per details given in excel file Outlook VBA and Custom Forms 11
F Excel VBA to move mails for outlook 365 on secondary mail account Outlook VBA and Custom Forms 1
J Dopey move - deleted profile Using Outlook 1
GregS Outlook 2016 Move Outlook to new computer? Using Outlook 4
witzker Macro to move @domain.xx of a Spammail to Blacklist in Outlook 2019 Outlook VBA and Custom Forms 7
G Move tasks up/down todo list by VBA Outlook VBA and Custom Forms 1
S Macro to move “Re:” & “FWD:” email recieved the shared inbox to a subfolder in outlook Outlook VBA and Custom Forms 0

Similar threads