使用兑换,如何将默认签名添加到外发电子邮件中?

发布于 2024-09-07 03:30:45 字数 1703 浏览 9 评论 0原文

这是我正在使用的代码。我花了一些时间查看救赎对象,但是,我什么也没想到:

    public static bool PopEmail(string domainUserName, string mSubject, string mBody, string mTo, string mCc = "", string mBcc = "", List<String> fileAttachments = null)
    {
        log.Info("Starting to Pop Outlook Email Message");
        RDOSession oSession = new RDOSession();
        try
        {
            oSession.LogonExchangeMailbox(domainUserName, string.Empty);
            if (oSession.LoggedOn)
            {
                RDOMail oMail = oSession.GetDefaultFolder(rdoDefaultFolders.olFolderOutbox).Items.Add("IPM.Note");
                oMail.Subject = mSubject;
                oMail.Body = mBody;
                oMail.To = mTo;
                oMail.CC = mCc;
                oMail.BCC = mBcc;
                if (fileAttachments != null)
                {
                    foreach (string file in fileAttachments)
                    {
                        object newFile = file;
                        oMail.Attachments.Add(newFile, Type.Missing, Type.Missing, Type.Missing);
                        newFile = null;
                    }
                }
                oMail.Display();
                Marshal.FinalReleaseComObject(oMail);
                oMail = null;
            }
            oSession.Logoff();
            Marshal.FinalReleaseComObject(oSession);
            oSession = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
            log.Info("Outlook Email has been Popped.");
            return true;
        }
        catch (Exception)
        {
            log.Error("Outlook Pop Email Failed.");
            throw;
        }
    }

谢谢,

Here is the code that I am using. I have spent some time looking at the Redemption objects, but, nothing jumps out at me:

    public static bool PopEmail(string domainUserName, string mSubject, string mBody, string mTo, string mCc = "", string mBcc = "", List<String> fileAttachments = null)
    {
        log.Info("Starting to Pop Outlook Email Message");
        RDOSession oSession = new RDOSession();
        try
        {
            oSession.LogonExchangeMailbox(domainUserName, string.Empty);
            if (oSession.LoggedOn)
            {
                RDOMail oMail = oSession.GetDefaultFolder(rdoDefaultFolders.olFolderOutbox).Items.Add("IPM.Note");
                oMail.Subject = mSubject;
                oMail.Body = mBody;
                oMail.To = mTo;
                oMail.CC = mCc;
                oMail.BCC = mBcc;
                if (fileAttachments != null)
                {
                    foreach (string file in fileAttachments)
                    {
                        object newFile = file;
                        oMail.Attachments.Add(newFile, Type.Missing, Type.Missing, Type.Missing);
                        newFile = null;
                    }
                }
                oMail.Display();
                Marshal.FinalReleaseComObject(oMail);
                oMail = null;
            }
            oSession.Logoff();
            Marshal.FinalReleaseComObject(oSession);
            oSession = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
            log.Info("Outlook Email has been Popped.");
            return true;
        }
        catch (Exception)
        {
            log.Error("Outlook Pop Email Failed.");
            throw;
        }
    }

Thank you,

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

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

发布评论

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

评论(2

你的呼吸 2024-09-14 03:30:45

签名实际上是由 Outlook 检查器对象在实例化时插入的,因此,如果您的代码在 Outlook 插件内运行,您可能可以尝试保存该项目,然后通过 作为 _MailItem 从 OOM 重新打开它>_Namespace.GetItemFromId,然后调用其 GetInspector 方法(您实际上不必对返回的检查器引用执行任何操作)。

请注意,我还没有对最初通过 RDO 创建的项目尝试过此操作。我通常在 OOM 中创建项目,然后创建 RDO 包装器。

如果您的代码在 Outlook 外部运行,则必须使用 OLE 获取对其 _Application 对象的引用,然后从那里提取 _Namespace 对象。如果您在没有安装 Outlook 的情况下使用独立 MAPI,则签名功能完全不可用。

The signature is actually inserted by the Outlook inspector object on instantiation, so if your code is running inside an Outlook addin you could probably try saving the item and then reopening it from the OOM as a _MailItem via _Namespace.GetItemFromId and then calling its GetInspector method (you don't actually have to do anything with the returned inspector reference).

Note that I haven't tried this with an item initially created via RDO. I usually create the items in OOM and then create an RDO wrapper.

If your code is running outside of Outlook you'd have to use OLE to get a reference to its _Application object and then pull the _Namespace object from there. If you are using standalone MAPI without Outlook installed the signature functionality is completely unavailable.

人心善变 2024-09-14 03:30:45

我已添加代码附加到 oMail.HTMLBody,该代码从 C:\Users\UserName\AppData\Roaming\Microsoft\Signatures 文件夹中读取签名。该文件是通过我们的一位开发人员编写的插件生成的,该插件从 Exchange 读取信息以确定用户名、职务、电话、传真等。

I have added code to append to the oMail.HTMLBody which reads the signature from the C:\Users\UserName\AppData\Roaming\Microsoft\Signatures folder. This file is generated via a plug in written by one of our developers that reads information from Exchange to determine User Name, Title, Phone, Fax, etc.

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