Extracting attachment's name from outlook email

Hello Forum,
I would really appreciated if you could advice me on how:

store in a variable the name of one attachement email that was received in my outlook inbox.

The idea is : i have several emails with attachments. So, i want to extract attachments names in a variable ( because my workflow will save the file in a folder path) and then il will use this variable to be able to save again the attachment with the same name BUT with a diferent extension. That’s the reason i need to store the name in a variable …

any suggestion on how to do it will be much appreciated.
Thanks

Hi @Ricchch

Please check those topic already solved

if none of the above helps, then feel free to ask

Regards

1 Like

@Ricchch

You can use For Each activity for the email to run the loop
Now you can choose a string variable and give as
mailMessage.Attachments.Select(function(x) x.Name).toArray()

Hope this may help you

Thanks,
Srini

1 Like

@Ricchch

You actually have an output already which gives you those

If you want all the attachments from all emails then after this activity use append to list or append to collection and append the data in loop

Cheers

1 Like

Hi @Ricchch

  1. Use “Get Outlook Mail Messages” activity onto your UiPath workflow.
  2. Configure the properties of the “Get Outlook Mail Messages” activity, such as specifying the folder (e.g., Inbox) and output variable to store the retrieved emails.
  3. Use a “For Each” loop activity to iterate through each email in the mailMessages.
  4. Within the loop, drag and drop the “Save Attachments” activity.
  5. Configure the properties of the “Save Attachments” activity, such as specifying the email (e.g., item), the folder path to save the attachment, and the output variable to store the saved attachment (let’s call it attachmentPath).
  6. After the “Save Attachments” activity, use an “Assign” activity to store the attachment name in a variable. For example, you can use the following expression: attachmentName = Path.GetFileName(attachmentPath).
  7. You can then use the attachmentName variable to save the attachment with a different extension or perform other operations as needed
    .
    I hope it helps.
1 Like

Thanks @fernando_zuluaga
I will work on that today.
Ricchch :handshake:

1 Like

Thanks @Srini84 :handshake:

Thanks @Anil_G
:handshake:

1 Like

Thanks @Nitya1 :handshake:

Hello @fernando_zuluaga
Thanks for helping.
I tried the third example but i have still problem to make it work
you will see in picture below my workflow, where i have already (it is not shown in the picture) filter email from outlook then:
step 1 : i use a Switch activity to filter by attachement name , just if the include some string patterns)
step2: just a message to control for my tests
step 3: in this activity i just apply for marking as read message
step 4 : just to eliminate color categories in a email
step 5: my main problem : i have problem to save the name of the attachement in a variable…would you help on that…

Thanks,

Hi @Anil_G and thanks for helping,
I am using a Switch scenario to catch an email individually instead of using a list variable (and the attachment target ) to save it. you could find the concept of my workflow here.

I have previously filtered the email by : unread and red category (it is not shown in the picture) then I use a Switch activity to verify string subject matches, then once an email respect that string pattern in subject, i use Get outloot mail message to mark as unread. then set outlook mail categories to erase color categories .
Finally (and heres is my problem) i want to store the name of the attachment in this email into a variable . just to be able to use this name after…

Any advise would be much appreciated.
Thanks

@Ricchch

Mail.attachment.Name is the one which would contain the attachment name right…so why are you using row(“soemyhing”) ?

Am I missing something?

Cheers

Thanks to all of you guys!
Finally, i could store the name in a variable :slight_smile: using:
CType(mail.Attachments.FirstOrDefault, Attachment).Name
I tried all the other suggestion but i couldn’t make it work for some reason.
Thank you very much for helping… :handshake:
Richch

2 Likes

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