如何获取Outlook发件人姓名
问题描述:
我想从我的c#windows应用程序中获取Outlook发件人姓名和发件人的电子邮件地址。
以下是我的代码但它会返回错误。请帮帮我。
Hi,
I want to get outlook senders name and senders email address from my c# windows application.
below is my code but it returns errors. please help me.
Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
MessageBox.Show(oMsg.SenderName.ToString()); // here is the error
MessageBox.Show(oMsg.SenderEmailAddress.ToString()); // here is the error
谢谢。
Thanks.
答
首先,请阅读Bernard Hiller的评论。
请参阅:
Outlook 2013: http://msdn.microsoft.com/en-us/library/office/ff861332.aspx [ ^ ]
Outlook 2003: http://msdn.microsoft.com/en-us/library/office/aa210946%28v=office.11%29.aspx [ ^ ]
VBA:
First of all, read Bernard Hiller comment.
See this:
Outlook 2013: http://msdn.microsoft.com/en-us/library/office/ff861332.aspx[^]
Outlook 2003: http://msdn.microsoft.com/en-us/library/office/aa210946%28v=office.11%29.aspx[^]
VBA:
Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)
myFolder.Display
Set myItem = myFolder.Items(2)
myItem.Display