Hi everybody. First post here.
I have a problem I’m kinda stuck with. The task is pretty simple - I just don’t know how.
Basically I need every mail that contains an attachment that has “Invoice” in its name, moved to a subfolder called “Sorted”. And that’s it.
I’ve tried to use the “For Each Email”, but I can’t sort based on attachment with that function.
I’ve tried to implement this sollution, but either it is outdated or I did i wrong.
I use the community edition of UIPath and for mail I use Outlook.
Hope someone can help. Cheers!
Basically, it might be like the following. Can you try this?
I’m missing the option “retrive attachments”.
But also: I belive this will only save the attachment to a windows folder. I need the email containing the attachment moved to a subfolder of “Inbox” (“Indbakke” in my picture. It’s danish)
I just understood your requirement. How about the following?
Condition of IF is
CurrentMail.Attachments.Cast(Of Attachment).Any(Function(a) a.Name.Contains("Invoice"))
This looks like something that would work.
I get an error though. I copy/pasted the line of code you wrote for the condition, but I get the following error:
Some of it is in danish, but it says that " ‘Attachment’ is ambiguous and imported from the name areas or types 'Microsoft.Exchange…" I honestly have no idea what that means.
It seems namespace matter. Can you try the following expression?
CurrentMail.Attachments.Cast(Of System.Net.Mail.Attachment).Any(Function(a) a.Name.ToLower.Contains("invoice"))
Note: I also modified it check as case-ignore.
No errors now! But it also didn’t work.
I tried to just get it to output the state of the condition, and it is false, although the first email in my inbox is an email with a file “invoice.pdf” attached to it.
To check filename of attachments, can you try to use the following expression using MessageBox?
String.Join(vbCrLf,CurrentMail.Attachments.Cast(Of System.Net.Mail.Attachment).Select(Function(a) a.Name))
That returns an empty message box
Can you check the mail is what you expect?
For example, set Breakpoint and check value of MailMessage in Local Panel or check
CurrentMail.Subject etc using Messagebox.
It is the correct mail. It’s subject is just “123456”
Hmm…It seems strange…
Can you try to set Breakpoint at the IF activity, then run debug mode?
Workflow will stop there, and we can check various value in Local Panel.
So can you check CurrentMail and its Attachements as the following?
You got it.
This seemes odd. If i read it correctly, it counts 0 attachements on the email?
It also looks like the name of the attached file(s) isn’t a part of “CurrentMail”
For now, can you try to upgrade UiPath.Mail.Activities pacakge to the latest preview version (1.13.1-preview)?
Upgrading to 1.13.1-preview fixed everything! It is working flawlessly now - Thanks a lot!
I am using this as the condition in the th IF-statement:
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.