.NET / Outlook interop and saving attachments: a mysterious except



Greetings,

This is a question about the .NET / Outlook interop, from a .NET novice. I’m
using C# and MS Visual Studio 2008, MS Outlook 2003 and Xobni (not sure if
that’s relevant).

QUESTION 1:
-=-=-=-=-=-=-
The code goes into my inbox, iterates over each message, and saves all
attachments to a directory. Each time I run the code, it successfully saves
approx 30 attachments but then throws an exception which I don’t understand.
Could anyone please shed some light on this?

Exception details and code are nicely formatted at:
http://forums.msdn.microsoft.com/en-US/csharpgeneral/thread/0ee08455-f9d0-45ad-a03e-b69c4417c4f7

QUESTION 2
-=-=-=-=-=-=-
In the same code, I added the following two lines (the ultimate goal is to
strip out the sender's domain and append it to the filename of each
attachment).
However, my app freezes when I request the MailItem.SenderEmailAddress
property.


Console.WriteLine("Title: {0}", item.Subject); // this one works fine
Console.WriteLine("Email: {0}", item.SenderEmailAddress); // this one freezes



.



Relevant Pages

  • RE: .NET / Outlook interop and saving attachments: a mysterious except
    ... Outlook's "object model security guard." ... Author of Microsoft Outlook Programming: ... approx 30 attachments but then throws an exception which I don’t understand. ... Exception details and code are nicely formatted at: ...
    (microsoft.public.office.developer.vba)
  • Re: Email disappeared
    ... Started OE to create new inbox and downloaded ... > from the inbox to another folder, all messages disappear, ... Because of this tendency of attachments to infect, Microsoft has now set OE to block all attachments. ... If you choose to adjust OE to allow attachments, make sure you save the attachment to disk first and then scan it with your antivirus software. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Save Attachments to directory based on attachment name
    ... The attachments are always going to be named 123456_Description.tif. ... Email comes into box2 inbox with two attachments 54454_docname.tif and ... Check for any additional emails in box2 inbox and repeat if necessary, ... Dim Inbox As MAPIFolder ...
    (microsoft.public.office.developer.outlook.vba)
  • Re: My Guess is This is Common--Attachments to E-Mail Not Accessible
    ... If you have then uncheck this box and you should get access to all attachments. ... Click on INBOX then right-click an empty bit of the TOOLBAR and click on CUSTOMIZE and find the icon called PREVIEW and double-click it to add it to the TOOLBAR. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: OEs automatic removal of access to attachments.
    ... If you have then uncheck this box and you should get access to all attachments. ... Load up Outlook Express and remove,if it's there,the tick against 'When Outlook Express starts, go directly to my Inbox'. ... Click on INBOX then right-click an empty bit of the TOOLBAR and click on CUSTOMIZE and find the icon called PREVIEW and double-click it to add it to the TOOLBAR. ... > previous inbox messages prior to upgrading, ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)

Loading