VBA Outlook SaveAsFile method creates empty file

Go To StackoverFlow.com

0

I have to process incoming mail and then save some xls-attachments as files. So, I get all attachments as

For Each att In mail.Attachments

(I really have all the attachments in att objects - I checked it by comparing att.FileName property with my attachment's names - it's ok.) But when I try to save my attachments as files, for example like this:

att.SaveAsFile "C:\test.xls"

The files are created, but they are always empty. Source files in attachments contain some data, text and pictures, but the saved files are empty.

2012-04-05 15:15
by chaika_sv
What version of Office are you running? Also, are you trying to save PICTURES and TEXT as .xls files - Gaffi 2012-04-05 17:43
You need to show the code that declares att and mail and how you are getting those references - JimmyPena 2012-07-06 18:59


1

It's hard to tell from your code what the problem might be. Using Outlook 2003, I got this to work just fine for any/all .xls attachments...

Sub TestSub()
    Dim mail As Outlook.Inspector
    Dim att As Variant
    Set mail = Application.ActiveInspector
    For Each att In mail.CurrentItem.Attachments
        att.SaveAsFile "P:\test.xls"
    Next att
End Sub
2012-04-05 17:42
by Gaffi
Ads