Remove extension while saving attachments

Not open for further replies.


Outlook version
Outlook 2013 32 bit
Email Account

I feel this is something different which i am asking. I have vba script which downloads the attachment through Outlook 2013. The attachments are saved to destination folder, every thing is okay. The only part that i what to change is the extension whatever be the extension i want to remove them and then save the attachment to the destination folder, because most of the files are in .dat extensions which is creating problems for further processing.

example : report.dat converts to report (flat file without extension)

The part of script is presented here so some one can provide help.

For Each Item In Inbox.Items
For Each Atmt In Item.Attachments

[some stuff working here for download]
FileName = "C:\Email Attachments\" & Atmt.FileName
Atmt.SaveAsFile FileName
i = i + 1
Next Atmt
Next Item

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
is the extension always 3 char? if so, left(atmt.filename, len(atmt.filename) -4) should work. if not, you need to find the dot first.

I'd probably use

filename = left(atmt.filename, len(atmt.filename) -4)

filename = "c:.... " & filename
Not open for further replies.