PDA

View Full Version : [SOLVED:] Save attachments from a specific email id to a folder in local drive.



anish.ms
11-01-2023, 03:23 PM
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.

Aussiebear
11-01-2023, 05:16 PM
Have a look here. https://stackoverflow.com/questions/52782539/outlook-2016-vba-to-save-attachments-from-folder-to-specific-loction

jdelano
11-02-2023, 06:29 AM
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) (https://www.slipstick.com/outlook/rules/outlook-run-a-script-rules/)

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 (https://support.microsoft.com/en-us/office/show-the-developer-tab-e1192344-5e56-4d45-931b-e5fd9bea2d45)) 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

anish.ms
11-02-2023, 01:41 PM
Thanks Aussiebear (http://www.vbaexpress.com/forum/member.php?3907-Aussiebear)

anish.ms
11-02-2023, 01:43 PM
Thanks jdelano (http://www.vbaexpress.com/forum/member.php?86815-jdelano)
But this code doesn't specify any email address. I understand that this code saves all the attachments.

jdelano
11-03-2023, 05:26 AM
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.

anish.ms
11-07-2023, 10:02 PM
Thanks jdelano
I think the VBA editor in new outlook 365 is hidden.

Aussiebear
11-08-2023, 01:01 AM
Did you try Alt F11?

anish.ms
11-08-2023, 01:35 AM
Yes, it's not working

Aussiebear
11-08-2023, 03:05 AM
According to Microsoft, what I suggested works on all versions other than the free online version.

jdelano
11-09-2023, 05:09 AM
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 (https://answers.microsoft.com/en-us/outlook_com/forum/all/is-there-a-way-to-access-vbadeveloper-in-the/2f7d5dd3-0ecd-43fc-a1aa-a1c91c958ade) 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.

anish.ms
11-12-2023, 10:40 PM
Thanks jdelano for your time and the detailed explanation.
I will go though it let you know

jdelano
11-13-2023, 04:04 AM
You're welcome, I hope you're allowed to switch back to the "regular" Outlook.

Gasman
11-14-2023, 02:43 AM
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/forums/threads/new-outlook-breaks-vba.329344/#post-1896309