Outlook attachments: wait for security scan to complete?

Hi. I’m using Studio 2023.4.3, and doing a for-each activity on the email messages in a specified inbox. It checks for attachments by file extension, e.g.

Email.Attachments.Where(function(x)x.Name.EndsWith(“.csv”)).Count > 0

and eventually saves the attachment(s) to a specified folder.

We’ve been getting some curious behavior from the automation with Outlook – for example, not finding attachments when clearly the email has an attachment. But like many large organizations, we have a security scan performed on attachments before they are available to read or download, and sometimes that scan can take several seconds. So I’m wondering:

a. What would happen if the bot tries to read, or even get metadata from, the attachments WHILE the scan is in progress? Would it not “see” any attachment at all?

b. Have any of your dealt with this issue? And if so, how did you solve it? (Other than adding a delay of X seconds in the workflow.)

I should add that it works fine sometimes, and other times it does not.

Thanks!

I highly suggest using the Office 365 activities instead of Outlook activities. It will avoid these kind of problems. There is some setup to be done to use them, but it’s worth it. It has greatly simplified email-based automations for us.

Thanks @postwick . Will definitely look into it. Any experience with the security scan question, or would it become a non-issue if using the Office365 activities?

I have not dealt with any security scan issues. Is this scan being done within Outlook, or by some security software to the saved attachment after you save it?

What do you mean by “not finding attachments”? What activity are you using, how is it set up, and what is the result you are getting vs what you are expecting?

It’s doubtful that a security scan would be causing the issue you are describing.

Hi @klem.joseph

please re use the below sequence. Instead of click activities you can add your download process steps, after that you can use file Exists activity (modern) or path exist activity( classic) you can make the assign value as true if its found or until you can retry scope how many times you need.
Sequence1.xaml (10.6 KB)

The scan happens within Outlook, as soon as we open an email message that has an attachment. But based on others in this thread, it sounds like the scan is not the culprit. Thanks!

Thanks for the code snippet. We are using the “mail activities” – see screenshots – so we are gathering info about the attachments BEFORE saving them to a folder. And we’re not using click or UI elements. It all seems to be metadata gathered without any UI interactions with Outlook.

It’s a Windows legacy bot, BTW. I have inherited it from another developer who’s no longer available so I’m studying the workflows to better understand the design. Seems like we might not even need to open Outlook client, since everything is being done in the background via mail activities.


okay better i would like to suggest to use WAIT FOR DOWNLOAD Activity.

please refer the below doc.

image

incase if you are getting issue with downloading file which means already csv file in attachment but bot unable to download ( are you trying to convey that)

Great – thanks so much for these tips and documentation @Baskar_Gurumoorthy

@klem.joseph below is your solution

  • Attachment Handling:
    • Be aware of potential security scans that might delay attachment access. Implement retries or waiting mechanisms (discussed earlier) to handle this.
    • Use activities like Save Attachment to manage attachments effectively.
      How to get the filename of attachment?

Best Practices UiPath

General Practices:

  • Error Handling: Always implement proper error handling using Try Catch activities. This ensures your automation gracefully handles unexpected situations and doesn’t crash.
  • Logging: Maintain a log of your automation’s activities, including successes and errors. This helps with troubleshooting and monitoring.
  • Performance Optimization: Avoid unnecessary loops or operations that might slow down your automation. Consider using efficient filtering and data manipulation techniques.
  • Reusability: Create reusable workflows or libraries for common tasks like sending emails or attaching files. This promotes code maintainability and reduces redundancy.
  • Security: If handling sensitive information, ensure secure practices like credential management and data encryption (if applicable).

Outlook Automation Specific Practices:

  • Connectivity:
    • Test email connectivity before starting automation.
    • Consider using the ExchangeApplicationCard activity from the UiPath.Mail.Activities package for a more robust connection (if available).
  • Filtering:
    • Use efficient filtering techniques to target specific emails instead of iterating through all emails.
    • Leverage properties like ReceivedTime , From , Subject , and keywords in the body to filter emails.
  • Attachment Handling:
    • Be aware of potential security scans that might delay attachment access. Implement retries or waiting mechanisms (discussed earlier) to handle this.
    • Use activities like Save Attachment to manage attachments effectively.
  • Dynamic Content:
    • If extracting data from email content (e.g., tables), use reliable methods like regular expressions or screen scraping (if necessary) to handle variations in email formatting.
  • User Interface (UI) Automation (if applicable):
    • If using UI automation for interacting with the Outlook desktop application, consider the potential for fragility due to UI changes.
    • Explore alternative approaches like the UiPath.Outlook.Activities package (if available) or the Outlook web API for more reliable automation.

Additional Tips:

  • Start Simple: Begin with basic email processing tasks and gradually increase complexity as you gain experience.
  • Test Thoroughly: Test your automation with various email scenarios to ensure it works as expected.
  • Utilize Community Resources: Leverage the UiPath Community Forum and documentation for help and learning opportunities.

You would not need to use Wait For Download with the Save Attachments activity, doubtful that will solve the problem.

Hi @klem.joseph

is that anything required further?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.