Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Outlook.Attachment SaveAsFile error

471 views
Skip to first unread message

Ben Wiersum

unread,
Jan 26, 1999, 3:00:00 AM1/26/99
to
I am writing a VB6 app that controls Outlook through its COM object model.

When I call an Outlook.Attachment object's SaveAsFile method I get an error
stating "Cannot save the attachment. Access is denied."

Any tips would be appreciated.

Outlook 97 (8.04.5619)
NT4 SP3
VB6


Ben Wiersum
bwie...@lplus.com


Chris Burnham

unread,
Jan 26, 1999, 3:00:00 AM1/26/99
to
Did you happen to check the Help Files for Forms? I realize you aren't
using Forms here, but this is where Outlooks Object Model is detailed,
including all Objects, Events, Methods, and Properties are detailed. Here's
the example provided for SaveAsFile:

SaveAsFile Method Example

This Visual Basic for Applications example uses the SaveAsFile method to
save the first attachment of the currently open item as a file in the My
Documents folder, using the attachment's display name as the file name.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveInspector.CurrentItem
Set myAttachments = myItem.Attachments
myAttachments.Item(1).SaveAsFile "C:\My Documents\" & _
myAttachments.Item(1).DisplayName
If you use VBScript, you do not create the Application object. This example
shows how to perform the same task using VBScript.

Set myItem = Application.ActiveInspector.CurrentItem
Set myAttachments = myItem.Attachments
myAttachments.Item(1).SaveAsFile "C:\My Documents\" & _
myAttachments.Item(1).DisplayName

Now, if your problem is NOT syntactical, the next question would be whether
or not OL97's Object Model supported the SaveAsFile Method. My list of new
Methods introduced in OL98 doesn't include this particular one, so I would
guess it WAS included in OL97.

You may need to post over to microsoft.public.outlook.program_forms for more
detailed help if the above information doesn't solve your problem.

--
Answers to many of the questions commonly asked here can be found in
Microsoft's Outlook FAQ:
http://support.microsoft.com/support/outlook/faq/ol98/

Regards,
Chris Burnham
Grand Rapids, MI

Ben Wiersum wrote in message ...

Ben Wiersum

unread,
Jan 27, 1999, 3:00:00 AM1/27/99
to
Thanks Chris. In my SaveAsFile call, I was only giving it a path name and
not the file name. Sending the path and file fixed the error.

Ben Wiersum


Chris Burnham

unread,
Jan 27, 1999, 3:00:00 AM1/27/99
to
Glad it worked, Ben. If you don't mind me asking--what does your VB app do?

--
Answers to many of the questions commonly asked here can be found in
Microsoft's Outlook FAQ:
http://support.microsoft.com/support/outlook/faq/ol98/

Regards,
Chris Burnham
Grand Rapids, MI

Ben Wiersum wrote in message ...

0 new messages