我猜dll有问题。
Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
// Get the MAPI namespace.
Microsoft.Office.Interop.Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
// Log on by using the default profile or existing session (no dialog box).
oNS.Logon(Missing.Value, Missing.Value, false, true);
// Alternate logon method that uses a specific profile name.
// TODO: If you use this logon method, specify the correct profile name
// and comment the previous Logon line.
//oNS.Logon("profilename",Missing.Value,false,true);
//Get the Inbox folder.
Microsoft.Office.Interop.Outlook.MAPIFolder oInbox = oNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
//Get the Items collection in the Inbox folder.
Microsoft.Office.Interop.Outlook.Items oItems = oInbox.Items;
// Get the first message.
// Because the Items folder may contain different item types,
// use explicit typecasting with the assignment.
// Microsoft.Office.Interop.Outlook.MailItem oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oItems.GetFirst();
// Microsoft.Office.Interop.Outlook.MailItem oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oItems;
foreach (Microsoft.Office.Interop.Outlook.MailItem mail in oItems)
{Activity.StartTime = mail.ReceivedTime;
Activity.EndTime = mail.ReceivedTime;
Activity.Details = mail.Subject;
Activity.Notes = mail.Body;}
我可以访问mail.Body,Subject等但我无法访问mail.Sender和mail.SenderEmailAddress 有人有这个问题吗? 我在这里看到https://msdn.microsoft.com/en-us/library/office/dn320330.aspx 它是一个mailItem属性,所以我不知道我的.dll是怎么回事。我已添加为参考C:\ WINDOWS \ assembly \ GAC_MSIL \ Office \ 15.0.0.0__71e9bce111e9429c \ Office.dll C:\ Program Files(x86)\ Microsoft.NET \ Primary Interop Assemblies \ Microsoft.Office.Interop.Outlook.dll 我是否需要添加更多.dll才能访问sender属性?