Create folder for each domain and then save all attachments from email Activity

Good morning Everyone,

Attached I have a bot that saves all email attachments to a particular folder and then prints them. It works great but I would like to take it a step further and group all the attachments by domain name of the sender. The group would then be saved to a folder that shows the domain name of the sender. I am still very new to the world of UiPath and would appreciate any advice given. Thank you.
Print my attachments.zip (6.5 KB)

Just read the domain of each email as you’re saving the attachments, split the sender email on @ to get just the domain, then create a folder (if it doesn’t already exist) with that name, and save the attachments. This will naturally group the attachments by domain. You don’t have to do any other complicated logic. Just save each email’s attachments in a folder named by the sender domain.

Would you be able to help with the syntax of this? I really appreciate the help!

@Grey_Angel,

Check any of the method mentioned below

'Using Split
emailaddress.Split("@"c)(1)

'Using Split with maximum number of substrings (more explicit)
emailaddress.Split(New Char() {"@"c}, 2)(1)

'Using Substring/IndexOf
emailaddress.Substring(address.IndexOf("@"c) + 1)

At what step in my bot would I add this and what activity would I use.

@Grey_Angel,

This would give you the domain name of the email address, using that you can check the folder exist or not using “Path Exists” activity. If the folder is not there then you can create it and store the attachments from that domain in that.

Ok this is helpful but what activity would I use to get the split?

Use Assign activity to get the split value in a variable

I think we are close but I think I am missing a step/activity.

Hi @Grey_Angel

Try this

DomainName=CurrentMail.SenderEmailAddress.Split("@"c)(1)

Regards,

Would this still work if it came from a .net for instance?

@Grey_Angel

Yes, it work

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