Hi,
I tried searching for my issue in forum but couldn’t find the right solution, apologies for reposting if already discussed.
I have attachments in Outlook(X,Y,Z…) while downloading and before saving it using save attachment i want to rename it uniquely as X_01,Y_02,Z_03 and save in a folder.
Why i want to rename it is because few of my inbox mails are having attachments with same name but content is different and the bot is skipping the files with duplicate name and is not saving it, hence i wanted to save the attachments with unique auto incrementing values.
Any other suggestion would be highly appreciated.
Hey! Excellent!!!. Thanks for the immediate response and yes that works but was just wondering is there a way to extract the original attachment name and then add (MMDDYYHHMMSS) as suffix?
May be something like this, i know its lengthy. Its just splitting the name by last “.” in your file name. If you know you will have only one “.”, it will be much easier.
Hey Thanks, that works but after downloading few attachments it throws error, i think i can fix that, my another concern is that i want to extract attachments only from particular email with certain subject lines and certain email addresses and mark those mails as read and move to another mail box.
For instance i want to download attachments from email having subject OR CONTAINING ‘xyz’,‘123’,‘SOMETHING’ sender’s address as ‘@xyz.com’,‘*@123.com’…and so on.
I am trying using like operator but it doesn’t seem to work.
Hi,
This works fine for single type of subject line and single sender’s email address but doesn’t work when i am entering multiple subject lines/receiver’s addresses for pattern matching.
mail.Subject Like (“Something,123,xyz") Or mail.From.Address.Contains("@services.com;@ountres.com;@xon”) AND mail.Attachments.Any
I even tried using OR after every subject pattern/Sender’s address and also used mail.subject.contains.
Hey thanks for your reply, really appreciate your effort but unfortunately it’s not working for me, i even tried using “”@SQL=" + “”“” + “urn:schemas:httpmail:subject” + “”“” + " like ‘%Uber%’" in my filters but it throws error.
I simply want to extract attachments from multiple sender addresses along with that i also want to extract attachments from mail having certain subject lines.
I am using get outlook mail messages.
I have given all options I can think of. If you want to filter on outlook level, then it’s going to be tough for you as the filters may not work as expected or you might be implementing in wrong way.
OR
Get all your emails and filter in your foreach loop as shown below :
mails.Where(Function(s) s.Attachments.Any AND ({ “abc”, “xyc”,
“Something” }.Any(Function(x) s.Subject.ToLower.Contains(x)) OR { “abc.com”, “xyz.com”,“@123.com”}.Any(Function(x) s.Sender.Address.ToLower.Contains(x))))
You can create the array’s dynamically
sub (string array) = ({ “abc”, “xyc”,“Something” }
mails.Where(Function(s) s.Attachments.Any AND (sub.Any(Function(x) s.Subject.ToLower.Contains(x)) OR dom.Any(Function(x) s.Sender.Address.ToLower.Contains(x))))
If it doesn’t help , someone should be be able to help.
This has filter and no filter solutions. For filter to implement mulitple search patterns implemented @ClaytonM idea (i don’t think he remembers). See if any of the solution works for you.
If you want to rename with sender or receiver username
First read your mail with your get mail activities(either “get outlook mail” or "get IMAP mail messages) the output of these activities is list
Take for each loop configure the type argument as system.net.mailmessage
ReadGmailMail.xaml (8.3 KB)
This is my file that i had developed for downloading the attachment from gmail. now i need to rename the downloaded attachment with user name. as you said where should i put for each activity to get the name .
@soumi_soumiya I tried this one but iam getting as folder name (inside that folder name it is saving that attachment)
Example: if my sender name is Aman, it’s creating Aman as a folder inside that its saving the attachment. If this is Fyn for you , you can do like this
First , for each loop configure type argument as (system.net.mailmessage)
Inside for each loop take save attachment activity, in mail message place in attachment place you can give as “yourfolderpath”+item.sender.user.displayname
Or else if you want to save the attachment with the sender name only then after downloading you can get recent file from a folder (with code) then you can use move file activity then you can change the name accordingly ( these steps all in inside the for each loop)