I got an AccessViolationException when trying to get the email address through MailItem.Sender. Address in Outlook 2007 (Windows XP). I do not get this error when I run the same code in Outlook 2010 (Windows 7).
Outlook.MailItem email = inbox.Items[i] as Microsoft.Office.Interop.Outlook.MailItem; Outlook.MailItem email Console.WriteLine("Subject: " + email.Subject); Console.WriteLine("Sender: " + email.Sender); <-- Exception Here! Console.WriteLine("Addr: " + email.Sender.Address);
Console: Error: System.AccessViolationException: Attempted to read or write protected memory. method: get_Sender ()
Makah source share