如何将标头添加到 Outlook 互操作邮件消息

问题描述 投票:0回答:0

我无法通过 smtp 将我的程序连接到交换服务器。因此,我使用 outlook interop 进行了测试并且似乎有效,至少对于发送电子邮件和添加附件而言。我现在的问题是将标题“disposition-notification-to”添加到邮件中。

Microsoft.Office.Interop.Outlook.Application application = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem mailMessage = application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem) as Microsoft.Office.Interop.Outlook.MailItem;

mailMessage.Subject = subject;
mailMessage.Recipients.Add(emailAddress);
mailMessage.HTMLBody = bodyString;
mailMessage.PropertyAccessor.SetProperty("urn:schemas:mailheader:disposition-notification-to", notificationAddress);

在设置属性时,我得到“异常抛出:program.exe 中的‘System.Runtime.InteropServices.COMException’”

我还没有找到一个例子,而且大多数情况下,像 mailkit 这样的其他库通常邮件项目有一个 Headers 字段。

感谢任何帮助的建议

c# wpf outlook office-interop email-headers
© www.soinside.com 2019 - 2024. All rights reserved.