I am experiencing what appears to be a security problem when attempting to save file attachments from MailItems in the default inbox of Outlook (have tried both 2000 and 2002 SP-1). the messages have been filtered to only save .txt attachments and I use the following code to attempt the save (myPath has been verified to exist)
mi = (Outlook.MailItem)InBox.Items.Item(x);
mi.Attachments.Item(z).SaveAsFile(myPath);
The error thrown is
'System.Runtime.InteropServices.COMException' occurred in OutlookTest.exe
Additional information: Cannot save the attachment. Access is denied'
The user is able to save the .txt files manually from within Outlook so I am not sure which security permissions are blocking this functionality. Any assistance would be greatly appreciated.
Cheers
Ernie
For anyone interested - I have found a solution.
The documentation indicates that the SaveAsFile() method takes a path string as its parameter. i.e. mi.Attachments.Item(z).SaveAsFile(myPath);
It actually requires the path + filename. Otherwise you get the Access Denied error - leading you to think there is a security issue.
Found this thanks to a forum thread on www.outlookcode.com
(http://www.outlookcode.com/threads.aspx?forumid=5&messageid=5371)
Cheers
Ernie
> I am experiencing what appears to be a security problem when attempting to save file attachments from MailItems in the default inbox of Outlook (have tried both 2000 and 2002 SP-1). the messages have been filtered to only save .txt attachments and I use the following code to attempt the save (myPath has been verified to exist)
>
[quoted text clipped - 10 lines]
>
> Ernie