View Single Post
  #5  
Old October 21st 08, 04:07 PM posted to microsoft.public.outlook.program_vba
Nigel RS
external usenet poster
 
Posts: 16
Default Saving email attachments

Sorted - there are non-printable characters in the MailItem.Body, I have put
in a function to strip these out and everything works as expected.

Cheers

"Nigel RS" wrote:

Hi Ken
I have changed the path by setting it directly

SaveFolder = "D:\"

not from itm.Body and it works OK!!

Very strange, as in debug mode the text string looks identical.

"Ken Slovak - [MVP - Outlook]" wrote:

The code looks OK offhand, what sort of path strings are you getting? Do the
paths other than the file name actually exist?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Nigel RS" wrote in message
...
I am using the following code, that runs from an outlook rule, to save
attachments
to a path defined by the contents of the email body. For example in my
email body I have the text string
D:\

I receive an error despite the path and file looking OK.

Help!

Sub ANYPATH(itm As Outlook.MailItem)

Dim objatt As Outlook.Attachment
Dim SaveFolder As String
SaveFolder = Trim(itm.Body)

For Each objatt In itm.Attachments
objatt.SaveAsFile SaveFolder & objatt.DisplayName
Next

Set objatt = Nothing

End Sub



Ads