PDA

View Full Version : File extension not added when saving attachments



snowbounduk
09-14-2010, 03:25 AM
Hi All,

I am using some code to save attahments. I am using the first seven characters of the filename and the extension (.mpp). However the attachment does not save with an extension.

Any help much appreciated.

Gordon


' Check each message for attachments
For Each Item In SubFolder.Items
For Each Atmt In Item.Attachments
' Check filename of each attachment and save if it has "mpp" extension
If Right(Atmt.FileName, 3) = "mpp" Then
' This path must exist! Change folder name as necessary. For this test Project Plans 1 - Change
FileName = "H:\Gordon Reports\Live Project Plans 1\" & Left(Atmt.FileName, 7) & "." & ExtString
Atmt.SaveAsFile FileName
i = i + 1
End If

snowbounduk
09-14-2010, 03:34 AM
No probs folks, I sorted it out myself. Could be I am learning how to use this stuff now!


' Check each message for attachments
For Each Item In SubFolder.Items
For Each Atmt In Item.Attachments
' Check filename of each attachment and save if it has "mpp" extension
If Right(Atmt.FileName, 3) = "mpp" Then
' This path must exist! Change folder name as necessary. For this test Project Plans 1 - Change
FileName = "H:\Gordon Reports\Live Project Plans 1\" & Left(Atmt.FileName, 7) & "." & Right(Atmt.FileName, 3)
Atmt.SaveAsFile FileName
i = i + 1
End If

Charlize
10-14-2010, 04:55 AM
What if you're filename is shorter then 7 characters ? And the reason why there was no extension was because the variable ExtString didn't had a value in it (guessing because I couldn't see any declarations).

Charlize