What is the order of download of the Download Email Attachments activity for inline attachments?

Hello.

I am developing an automation that gets outlook mail messages containing inline images and downloads the images using the Download Email Attachments activity which uses connectors and which downloads to the Temp folder.

The inline images in the body of the message can also be downloaded using this same activity.The mails i am receiving do not contain any regular attachments,only inline.

I am curious about the order in which these attachments can be downloaded.I heard it’s the same order as the order of the attachments in the Attachments collection but that doesn’t say much.

It doesn’t help that the downloaded files all have gibberish names like “qWyeQGQ.ekb.png” that do not correspond to the names in the AttachmentNamesList or the names of the files inserted in the mail by the sender.

To give the inline images an auto-generated index name when downloading them, follow these steps in UiPath:

  1. Get Mail Messages: Use the Get Mail Messages activity to fetch the emails with inline images.
  2. For Each Loop: Use a For Each loop to go through the attachments of each email.
  3. Check for Inline Images: In the loop, check if the attachment is an inline image (using Content-Disposition).
  4. Download and Rename with Auto Index: Download each inline image and save it with an auto-incremented index as the filename.

Here’s how you can implement this in UiPath:

Steps:

  1. Get Mail Messages:
    Set up the Get Mail Messages activity to fetch emails from your inbox.

  2. For Each Activity:
    Loop through each email’s attachments using a For Each activity.

  3. Check Inline Attachments:
    Use an If activity to check if attachment.ContentDisposition.Contains("inline").

  4. Download Inline Images with Index:
    Inside the If activity, use Download Email Attachments to download the attachment. To rename it with an index, create a variable (e.g., fileIndex), and increment it each time an inline image is processed.

Example:

fileIndex = 1  ' Initialize the index variable

For Each email In mailMessages  ' Loop through emails
    For Each attachment In email.Attachments  ' Loop through attachments
        If attachment.ContentDisposition.Contains("inline") Then  ' Check for inline image
            ' Build the file path with an index
            filePath = "C:\Your\Download\Path\image_" & fileIndex.ToString() & ".png"
            
            ' Download the inline image with the auto-generated name
            Download Email Attachments: attachment -> filePath
            
            ' Increment the index
            fileIndex = fileIndex + 1
        End If
    Next
Next

Key Points:

  • fileIndex starts at 1 and increments by 1 for each inline image, giving each image a unique name like image_1.png, image_2.png, etc.
  • You can adjust the file extension (.png) based on the actual type of image you’re downloading.
  • This process will automatically download all inline images from the emails and assign them sequential names.

This approach is simple and helps you organize inline images with auto-generated names.