Hi guys a quick one…So there is an attachment that is sent from a web application into my outlook, then I need to save the attachment to a folder I have created locally but then I need to change it’s name and give it a name of a policy number from an excel file(a variable I already created) e.g…
123456.pdf
Use Get outlook mail messages activity.Use Filter by giving mail id or subject
In for loop use save attachment it will save your attachment in your local folder
Then use Rename file activity then it will rename your file
Try this. use the below query after Get Outlook mail Messages.
attachmentFileName As String = (From mail In mails
Where mail.Attachments.Count > 0
From attachment In mail.Attachments.Cast(Of Attachment)()
Let attachmentFilePath = "C:\Attachments\" & attachment.Name
Let newAttachmentFilePath = "C:\Attachments\" & policyNumber & ".pdf"
Select File.Move(attachmentFilePath, newAttachmentFilePath)).FirstOrDefault()
Give your directory path where do you want to save.
Hi Anelisa_Bolosha1,
If you want to use the first element of the array then you can use checkfiles.FirstOrDefault(), if you need the second element then you can use checkfiles(1). But if you need to change the name for each element into the array of strings then you can use a for each activity.
So what I want to accomplish is to rename the one I just downloaded from outlook then save in that folder or download and rename after…but keeping in mind there might be other documents already there on the folder.
Hi@Anil_G, I have already have that activity in place, so it will first check if there are any filrs on a local folder that it wants to download in, if yes then it clears and download the attachment and save it
Hi @pavan_kumar5 , so my process is like this:
I have an excel file with policy numbers
I read the first number i take it to a web application to search for an attachment with it,attachment comes back and is sent to my outlook with a different name(dynamic names).
So I am suppose to download the attachment to my local folder and save the attachment with that policy number 1 I read from the excel file.
Bot continues to read another policy number from excel file then save attachment 2 with policy number 2 and so on…
Hi @jose.ordonez1 ,this solution is working but then it only does it for one attachment, it downloads and renames the first one it downloads, when it downloads the second attachment from outlook it breaks:
Please help how can I make sure on the rename every attachment is named according to a different name for my case ,named as policy number it got from excel…please see below the explanation of how the process goes
That might be because of the rename field…you need to use the dynamic name like the invoice number or so that you are getting instead of static name that is aready present
@Anelisa_Bolosha1 initially save attachment in a folder and then use Move File Activity with YourFolderPath\NewName Note: For every file must have different name in order to save those in a single folder!!