(Outlook 2010) 在 C# 中获取邮件标头

发布于 2024-11-05 14:38:34 字数 592 浏览 2 评论 0原文

我从这里改编了 Ken Slovak 的代码来阅读发送邮件之前,邮件上有 MailItem 标头,但我的标头字符串显示为空。这仅适用于收到的消息吗?如果是这样,在撰写转发/回复/回复全部之前拉入原始邮件的标头的好方法是什么?

这是我重新完成的代码:

        Outlook.PropertyAccessor oPA = msg.PropertyAccessor as Outlook.PropertyAccessor;
        const string PR_MAIL_HEADER_TAG = @"http://schemas.microsoft.com/mapi/proptag/0x007D001E";
        try
        {
            string strHeaders = (string)oPA.GetProperty(PR_MAIL_HEADER_TAG);
        }
        catch { }

谢谢

I've adapted Ken Slovak's code from here to read MailItem headers on a message before it is sent, but my header string is coming up as empty. Does this only work on received messages? If so, what would be a good method for pulling in the headers of the original message before composing Forward/Reply/Reply-To-All?

Here is my re-done code:

        Outlook.PropertyAccessor oPA = msg.PropertyAccessor as Outlook.PropertyAccessor;
        const string PR_MAIL_HEADER_TAG = @"http://schemas.microsoft.com/mapi/proptag/0x007D001E";
        try
        {
            string strHeaders = (string)oPA.GetProperty(PR_MAIL_HEADER_TAG);
        }
        catch { }

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野心澎湃 2024-11-12 14:38:34

仅当原始消息发送后,才会填充消息标头。我尝试了您的代码,它返回了我收到的邮件的消息标题。不过,当我尝试访问该消息时,确实收到了安全弹出窗口。

The message headers will only be populated once the original message has been sent. I tried your code and it returned the message headers for mail that I had received. I did get the security popup when trying to access the message though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文