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

标签 c# selenium outlook

我正在使用 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());
}

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

关于c# - 如何从电子邮件中获取收件人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40912573/

相关文章:

c# - UWP 中的 Process.Start

c# - dotnet 5 CLI 在 centos 8 上不提供 https

selenium - Java Selenium - 使用 xpath 搜索未找到搜索元素

outlook - ics文件问题

c# - 优化 Entity Framework 查询

c# - Visual Studio 团队服务 : Build Error (Assembly reference cannot be resolved)

java - Selenium Web 驱动程序 - 在循环内等待 (Java)

python - 如何在 Selenium Python 中正确格式化元素?

encoding - Outlook 2003/2010 主题编码

c# - 如何根据唯一标识符动态创建安装文件?