Save Outlook Attachment with a different name?

Hey everyone,

I get an excel doc. from mail and I save the attachment to a folder using save attachment activity.

I want to save this excel with a different name, how can I make this happen?

Please help.
Thank you,

1 Like

Hi @berkaykor,

Check This pic for renaming the attachment place this inside for loop.

Capture

  1. The filepath is the destination path for move file, the path is the original path.
    2.The file path and the path are same folder path but except the file name.

Thanks,
Neelima.

1 Like

Hi,

I also used “Invoke code” and FileStream:
image

Using fs As New FileStream(pathToSave, FileMode.Create)
att.ContentStream.CopyTo(fs)
End Using
savedFile = pathToSave

Where “att” is an attachment object (Net.Mail.Attachment) from Email and “pathToSave” the path string where you want to save the file.

Gio

1 Like

this looks simple and good but the name of the attachment file is random so I would also need something to also get the name of it to be able to give the path to “move file” activity.

@berkaykor When using the Save Attachments activity you have the option to set as an output the list of the Attachments. You can loop through this list and get the filepath of the .doc file. Hope it helps! :slight_smile:

Edit: There is also the option to Filter the attachments names and retrieve only .doc files e.g. “.(doc|DOC)$”

When I use the filter option “.(pdf|PDF)$” (its a pdf file) and output the save attachments without giving a folder path, i would get the list of only pdf items in the output variable, correct?
lets say output variables name is AttList
Then I will loop through AttList with for each activity and get the name of the pdf file.
Then I will move the file to the directory path with a new name.

Is this the way to do it?