Consulting

Results 1 to 14 of 14

Thread: Save attachments from a specific email id to a folder in local drive.

  1. #1
    VBAX Mentor
    Joined
    Nov 2020
    Location
    Cochin, Kerala
    Posts
    314
    Location

    Save attachments from a specific email id to a folder in local drive.

    Hi Experts,

    Is there an inbuilt option in outlook 365 to save the attachment from a particular email to a folder in the local drive? If negative, is it possible to do it using VBA?. I understand from my search that it can be done using power automate.
    Could you please share any reference links if you have.

    Thanks for your response.

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    VBAX Regular
    Joined
    Sep 2023
    Posts
    97
    Location
    You can use a rule to launch a VBA script (macro) - you need to re-enable the "run a script" option for rules though. You can do it via Run-a-Script Rules Missing in Outlook (slipstick.com)

    Then your code that you want run would be added to the "ThisOutlooSession" module in Visual Basic (if you don't already have the developer tab enabled, you'll need to enable it Show the Developer tab - Microsoft Support) this code should do what you need. This hasn't been fully tested but it should work or be pretty close.

    You need to change the value in yourPath to well, the path you want these attachments saved.

    Public Sub SaveAttachmentsFromEmail(attachmentEmail As Outlook.MailItem)
    
        ' when Outlook calls the script from the rules, it passes the email item
        Dim att As Attachment
        Dim attCount As Integer
        
        Dim yourPath As String
        yourPath = "F:\Temp\"
        
        ' loop through the attachments of the email and save them
        attCount = 0
        For Each att In attachmentEmail.Attachments
            attCount = attCount + 1
            att.SaveAsFile yourPath & att.FileName
        Next
        
        MsgBox "There were " & CStr(attCount) & " attachment(s) saved."
        
    End Sub
    edit: formatting was acting up

  4. #4
    VBAX Mentor
    Joined
    Nov 2020
    Location
    Cochin, Kerala
    Posts
    314
    Location
    Thanks Aussiebear

  5. #5
    VBAX Mentor
    Joined
    Nov 2020
    Location
    Cochin, Kerala
    Posts
    314
    Location
    Thanks jdelano
    But this code doesn't specify any email address. I understand that this code saves all the attachments.

  6. #6
    VBAX Regular
    Joined
    Sep 2023
    Posts
    97
    Location
    You create a rule for the email address and call the script. Outlook will send the email to the script. Check out the link on running a script from an Outlook rule.

  7. #7
    VBAX Mentor
    Joined
    Nov 2020
    Location
    Cochin, Kerala
    Posts
    314
    Location
    Thanks jdelano
    I think the VBA editor in new outlook 365 is hidden.

  8. #8
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Did you try Alt F11?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  9. #9
    VBAX Mentor
    Joined
    Nov 2020
    Location
    Cochin, Kerala
    Posts
    314
    Location
    Yes, it's not working

  10. #10
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    According to Microsoft, what I suggested works on all versions other than the free online version.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  11. #11
    VBAX Regular
    Joined
    Sep 2023
    Posts
    97
    Location
    I was looking around and it does seem like the new Outlook lacks this feature at the moment Is there a way to access VBA/Developer in the latest version of - Microsoft Community as this thread seems to confirm. The new Outlook is basically a PWA for the Outlook.com.

    I flipped the switch to "Try New Outlook" and you can see it is highly nerfed. Luckily you can flip the switch back to the previous version. I sent feedback selecting missing functionality and switched back to the Outlook I had.
    Attached Images Attached Images

  12. #12
    VBAX Mentor
    Joined
    Nov 2020
    Location
    Cochin, Kerala
    Posts
    314
    Location
    Thanks jdelano for your time and the detailed explanation.
    I will go though it let you know

  13. #13
    VBAX Regular
    Joined
    Sep 2023
    Posts
    97
    Location
    You're welcome, I hope you're allowed to switch back to the "regular" Outlook.

  14. #14
    VBAX Regular
    Joined
    Nov 2020
    Location
    Swansea,South Wales,UK
    Posts
    93
    Location
    I *thought* the issue with this new outlook, was that you cannot control it with VBA?, thereby breaking many systems?

    https://www.access-programmers.co.uk.../#post-1896309

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •