all groups > dotnet interop > october 2004 >
You're in the

dotnet interop

group:

Bug in Office Interop using SaveAs?


Bug in Office Interop using SaveAs? Jediah L.
10/26/2004 11:55:24 PM
dotnet interop:
The following code snippet fails when trying to save a mailitem to a windows
folder:

I've tried many variations of path - If i supply a file name I get an
"Invalid Parameter" error - so i'm pretty sure it just wants path - and when
I supply path (with \ or without \ as the last char) this is the error when
I get.

Here is an example of the code:

if(oItem is Outlook.MailItem)
{

Outlook.MailItem oMailItem = oItem as Outlook.MailItem;

oMailItem.SaveAs(path, OlItemType.olMailItem);

}



The error is:



{@"Can't write to file: c:\temp\outlook\Inbox\discover\testfolder.
Right-click the folder that contains the file you want to write to, and then
click Properties on the shortcut menu to check your permissions for the
folder." }



I checked the folder - and it is set readonly - I uncheck and apply - and
check the property again - and it is once again read only.

I only have problems writing to the folder through outlook and the interop -
I can write through the file system object - or manually through explorer,
or even through outlook directly....



I found this article which seems to explain perhaps why I can't remove the
'readonly' setting:



http://www.winnetmag.com/Article/ArticleID/24940/24940.html



But still doesn't explain why outlook is the only program that has a problem
with that value...



Any help would be appreciated!









Re: Bug in Office Interop using SaveAs? Jediah L.
10/27/2004 1:17:34 PM
Well it appears the bug was partially my fault. :)

The Path does need to include the file name, for some reason, the second
parameter would not accept any of the valid values except Missing.Value...

Once I stopped trying to dictate what type of item was being saved - it
stopped throwing the "Invalid Parameter" error - and once I started
specifying the file name - it stopped throwing the "Read Only" error.

Additionally - research seems to suggest that Folders are always set "Read
Only" in XP.. oh well.. :)


[quoted text, click to view]

Re: Bug in Office Interop using SaveAs? v-phuang NO[at]SPAM online.microsoft.com (
10/28/2004 2:21:42 AM
Hi,

Cheers!
It seems that the problem has been resolved.
If you still have any concern on this issue, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
AddThis Social Bookmark Button