Skip to main content
 首页 » 编程设计

c#之如何从电子邮件中获取收件人

2024年02月05日36bhlsheji

我正在使用 Outlook.Interop 以从收到的电子邮件中获取 Html 正文。 我正在尝试获取收件人的电子邮件地址,但只获取收件人的姓名而不是完整的电子邮件地址。

 Application myApp = new ApplicationClass(); 
            NameSpace mapiNameSpace = myApp.GetNamespace("MAPI"); 
            MAPIFolder myInbox = mapiNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox).Folders["digitel"]; 
 
            List<MailItem> ReceivedEmails = new List<MailItem>(); 
             
            foreach (MailItem mail in myInbox.Items) 
            { ReceivedEmails.Add(mail); } 
 
            var Recipients = ReceivedEmails[0].Recipients.ToString(); 
            

请您参考如下方法:

检查以下片段:

foreach (Outlook.Recipient recip in ReceivedEmails[0].Recipients) 
{ 
    Debug.WriteLine(recip.AddressEntry.GetExchangeUser().PrimarySmtpAddress.ToSt‌​‌​ring()); 
} 

如果您有任何问题,请告诉我:)!