Mail filter

Hello i have a mail that has 2 folders in it. 1 called RPA and one called Read email
I want the robot to only perfrom actions on mails that has attachment called “UTSKRIFT M3.pdf”
When the email recieves this mails the robot will get that mail download the attachment and store it in a folder, it will then mark the email as read and move it to the folder called Read email in the outlook.
Want this to go in a loop also until all mails that has UTSKRIFT M3 has been read, then it can move forward on its next task

Hi @langsem

Use get outlook message and mention the folder name with mail messages
Can not Read outlook mail from Custom Folder in outlook

Got that to work, next step its to make it look for mails that contains attachment with the name “UTSKRIFT M3.pdf” the mark it has read, download the pdf store it locally in a folder, then move the read email to another outlookfolder and mark as read

well the filter can’t be applied in outlook mail activity with Filter property especially with attachment name, where we can only filter like whether attachment is there or not, with HASATTACHMENT

But still we can check with the attachment name like this
–use a get outlook mail activity or any mail activity and get the output as a variable of type mailmessage collection named out_mailmessage
–use a for each loop and pass the variable out_mailmessage as input and change the type argument as mailmessage in for each loop
–inside the for each loop use a if condition like this
item.Attachment.Name.ToString.Contains(“UTSKRIFT M3.pdf”)
if this condition gets passed it will go to the THEN part of if condition where we use a activity called MOVE OUTLOOK or MOVE EXCHANGE mail activity and mention the folder path and mail input as item

–Then to mark the mail as read after validation get the subject of that mail being inside the THEN part of if condition like this with a variable of type string
out_subject = item.Subject.ToString
–now use a get outlook mail activity and pass the filter property as "[Subject]=’ " + out_subject + " ’ "
–this would mark them as read with the property “Mark as read” enabled
but make sure that in the very first get mail activities disable the Mark as read property
then only this would work

Hope this would help you
Cheers @langsem

Hi @langsem

Based on the condition you can use read pdf by looping it and use move outlook messages activity


Like this ?

I am getting a error Attachement its not a member of system,.net.mail.mailmessage

Change the type argument property in for each loop as mailmessage buddy
Cheers @langsem


its alrdy a mailmessage for the mail property in each

Ok managed to move the mail to the folder and also move the attachment to local. But its thowring an error upon move outlook filde to folder. Its making a copy also :confused:

1 Like

What was the error buddy

Element was copied instead of moving, because the original element could not be deleted. cant delete element. THe orignial element is moved or already deleted. else you dont have access Main.xaml (9.8 KB)

also its when saving on my local its storing all files, and i just want the pdf