Forum Discussion
VBA - Retrieve emails Attachment & Download
Thank you for your input sir! The VBA is 100x faster than PowerAutomate. If this task can be accomplished in vba code I rather go to that route. The gentleman told me that it can be done in vba. I just need to modify the code a little bit for my tasks. If there's no chance that cannot be done in vba, then, I will think with something else.
- NikolinoDEMay 11, 2024Gold Contributor
Mr. Patrick2788 idea of using Power Automate is also very interesting.
The speed of execution can depend on various factors, including the complexity of the task, the efficiency of the implementation, and the environment in which the automation is running. Comparing Power Automate to VBA in terms of speed can be nuanced.
In summary, while VBA might have certain performance advantages for specific tasks executed locally, Power Automate offers advantages in terms of ease of development, scalability, and integration capabilities. The choice between the two depends on factors such as the complexity of the task, the need for integration with external services, and the user's familiarity with each platform.
For your specific case of retrieving email attachments from an Exchange server mailbox, i think both Power Automate and VBA can accomplish the task effectively.
But in the end, you are the one who has to decide which solution is best for your project.
Here is an small outline of how you can set up a flow in Power Automate to achieve your task:
- Trigger: Start with an appropriate trigger based on when you want the flow to run. Since you want to process emails, you can use the "When a new email arrives" trigger from the Outlook connector.
- Condition: Add a condition to filter out emails from specific senders or with specific subjects. In your case, you would filter emails based on the sender's email address.
- Get Attachments: Within the condition, use the "Get attachments" action to retrieve attachments from the email.
- Save Attachments: Use the "Create file" action from the OneDrive or SharePoint connector to save the attachments to a specified folder in your network.
- Send Email (Optional): Optionally, you can add an action to send a follow-up email to the sender if no attachment is found in the email.
- Handle Unread Emails (Optional): To handle only unread emails, you can add a condition at the beginning of the flow to check if the email is unread before processing it.
To create such a flow, follow these steps:
- Go to the Power Automate portal (https://flow.microsoft.com) and sign in.
- Click on "Create" in the top navigation bar and select "Automated cloud flow."
- Choose the appropriate trigger based on your requirements, such as "When a new email arrives" from Outlook.
- Configure the trigger by signing in to your Outlook account and specifying any additional parameters such as folder, subject, sender's email address, etc.
- Add a condition action and configure it to filter emails based on the sender's email address.
- Within the condition, add the "Get attachments" action and configure it to retrieve attachments from the email.
- Add the "Create file" action and configure it to save the attachments to a specified folder in your network.
- Optionally, add actions to send follow-up emails or perform other tasks based on your requirements.
- Save the flow and give it an appropriate name.
- Test the flow to ensure it's working as expected.
The steps were processed using AI.
By following these steps, you can create a Power Automate flow to automatically download attachments from emails sent by specific senders and save them to a network folder.
- TTC-BlueHill1May 16, 2024Copper ContributorHello Sir,
I was able to go 'tool's and check in 'Microsoft Outlook 16.0 Object Library', but when I ran the code I got this error now "Run-time error - 2147221233 (8004010f). The attempted operation failed. An object could not be found".
Please let what need to be done for me to run this code.
Thanks again! - TTC-BlueHill1May 15, 2024Copper ContributorThank you both! I will explore both programs and decide which one is best for this project.
I will keep your guys posted on my progress.
Again million thanks!