I need to save email attachments only if the following conditions apply for the If statement:
- “listMailmsg(N).Attachments.Count>0” AND
- the attachments need to be only of type “.pdf”
I don’t know what is the syntax to check that the filename for the attachment is “.pdf”
N is a counter for a loop which needs to go through a list of mail messages and save only pdf files for VALID EMAILS to a folder OR if there are no attachments or a VALID EMAIL then it needs to send out a message informing the user that there is no attachment.
The workflow is not working at the moment though I will attach it, I just need to specify these two arguments for the “If” statement.Main.xaml (90.9 KB) project.json (985 Bytes)
this is perfect while for this
the condition should be like
Hope this would help you
When you save the atachments, you receive as output a “IEnumerable” where every single value is a Complete path of every single File. So you can ask in the If (inside a for each item): attachment(0).EndsWith (“.pdf”)
It should work.
I cannot find the “.Name” after the “.Attachments”
There are different attachment types, “.png”, “.pdf”, needs to save only the “.pdf”
Is there no other way to do this because the “Else” part of the “If” is also quite important as it needs to send out an error email to the client if there has not been a “.pdf” attachment found? So if I only have the “listMailmsg(N).Attachments.Count>0” as the argument then it does not execute the else part where for instance it finds a “.png” attachment (being a logo, etc.) btw why does Ui Path not just save the actual attachment only? Why is it saving things on the email that have not been directly attached?
So I need to be able to identify the attachment type as well and get that information as string/Boolean if possible.
Okay I tried the “If” within the “For each” and I am unable to get the “.EndsWith” after.
if possible can i have on the property panel of For each activity
Refer attached. Is iterating through “System.Net.Mail.AttachmentCollection”
How about this:
listMailmsg(N).Attachments.Where(function(x) x.Name.EndsWith(“pdf”)).Count > 0
(not tested, though)
Thanks @J0ska, this worked well. Please can you explain this part:
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.