Using Classic Outlook on Windows for personal email, calendar, and contact management
Hello Rupal,
Welcome to the Microsoft Community.
From your description, sorry to hear that you have experienced some issues.
Based on my understanding, you want to save the attachment from a specific email address to local drive by using VBA, right? If it's correct, may I know what version of outlook you are using?
As a workaround you could follow these steps using VBA script to achieve your requirements using classic outlook for windows.
· Automatically download Outlook attachments to a folder with VBA and rule
1. Open outlook App
2. Press Alt + F11 to open the Microsoft Visual Basic for Applications window.
3. On the left pane right click on Modules -- Insert > Module, and then paste below VBA script into the newly opened Module window.
Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem)
Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
sSaveFolder = "D:\attachment"
For Each oAttachment In MItem.Attachments
oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
Next
End Sub
Note: Need to change value (sSaveFolder = "D:\attachment")
With your drive and folder on your HDD in our example we donload attachment on Drive D folder name attachment.
Save the VBA script and close the Microsoft Visual Basic for Applications window.
· Registry to enable run a script on outlook rule
For security reasons Microsoft disabled this option you will need to Create Regedit to enable it.
- Close outlook
- Right-click the Start button, and click Run
- Type Regedit , and click OK.
4. Run Regedit and locate the key:
- HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Security
6. Right click the right windows and create a new DWORD (32-bit) Value.
7. Name that new entry EnableUnsafeClientMailRules and set its value to 1
· Create outlook rule to run script
1. Go to the File - Manage Rules & Alerts.
2. In the opening Rules and Alerts dialog box, please click the New Rule button on the E-mail Rules tab.
3. In the Rules Wizard dialog box that appears, please select theApply rule on messages I receive option, and click the Next button.
4. In the Rules Wizard (Which condition(s) Select apply with specific words in the sender address and add email address for example to apply on all Gmail sender address.
5. In the following Rules Wizard Check the run a script option
- Click the blue underlined "a script" text to open the Select Script dialog box. Here, choose the script you added in Step 2 and click the OK button.
- Click the Next button to proceed.
- In the Rules Wizard (Are there any exceptions?) dialog box, please click the Next button directly.
- In the last Rules Wizard dialog box, please name the rule in the Step 1 box,
- and click the Finish button.
IF above steps not successfully achieve your requirements,
Microsoft has separate channel resources, could you please place your concern on this dedicated VBA programming questions?
I am sure that our experts from that team can address your query effectively and accurately.
• Note: Please understand that our initial reply may not always immediately resolve the issue. However, with your help and more detailed information, we can work together to find a solution.
Thanks for your patience and understanding. Should any uncertainties arise subsequently, please feel free to seek assistance once again.
Best regards, Tan-Ly - MSFT | Microsoft Community Support Specialist