Save attachment / MS Outlook Email VBO
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
22-03-19 01:23 PM
Hello,
I save email attachment using - MS Outlook Email VBO / task *save attachment*.
While saving attachment I want to rename the file in order to prevent from name duplication.
The file name stays unchanged. Could you please Support here?
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
22-03-19 04:49 PM
Hi Radoslawrajnert,
I looked into this action and it seems like the ""File Name"" variable is not used anywhere (more advanced programmers - please correct me if I'm wrong). It may be a mistake in the code. Anyway ""File Name"" would be used only to determine which file You want to download from the email (and not the new name of the attachment).
If You want to rename specific file, use object ""Utility - File Management"" and action ""Move File"". Just specify there the same path but different file names and it should do the job.
Best regards
Michal Szumski
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
22-03-19 05:23 PM
I haven't looked at that action in a few months, but last I looked it's just a mistake in the object. 'Save Attachment' calls 'Save Attachments' and is supposed to pass over the File Name to be used to limit the attachment download to the specific name you give it. It was never intended to rename the attachment as it is being downloaded. I agree that this is annoying, but it's not a very difficult change to make if you want it to rename the file during download. Just copy the action and edit the code stage so that it gives a new name to the file before saving.
Without editing the code stage or without creating your own action, the way Michal describes is the standard way to use it. In my opinion, the easiest way to do this while also being safe is to have a temporary folder that you always delete all files from before downloading attachments to it. Then you grab whatever attachment from that folder/directory that you want and move/rename the file to the folder you really wanted to download it to.
Dave Morris, 3Ci at Southern Company
Dave Morris, 3Ci at Southern Company
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
25-03-19 04:23 PM
Hi guys,
Many thanks for your help!! I try to use the logic mentioned by david.l.morris.
Can you help me to adjust the code so that the file is saved always with the same name. e.g. "newfile.xls"
Dim app = CreateObject("Outlook.Application")
Dim _nameSpace = app.GetNameSpace("MAPI")
Dim item = _nameSpace.GetItemFromID(Entry_ID)
If item Is Nothing Then Return
If Not Folder_Path.EndsWith("\) Then Folder_Path &=""\"
For Each attachment As Object In item.Attachments
 If attachment.Type = 1 AndAlso attachment.FileName Like File_Pattern Then
  attachment.SaveAsFile(Folder_Path & attachment.FileName)
 End If
Next
Â
Â
Â
Â
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
25-03-19 07:25 PM
Change:
attachment.SaveAsFile(Folder_Path & attachment.FileName)
To:
attachment.SaveAsFile(Folder_Path & ""newfile.xls"")
