从自定义应用程序以编程方式发送电子邮件已停止使用最新的Outlook 365更新 [英] Sending emails programmatically from the custom application stopped working with latest Outlook 365 update

查看:56
本文介绍了从自定义应用程序以编程方式发送电子邮件已停止使用最新的Outlook 365更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从上一次Outlook 365更新以来,以编程方式从.NET应用程序发送电子邮件已停止,并显示错误消息对不起,出了点问题.您可能要重试".

Since the last Outlook 365 update, the sending of email programmatically from the a .NET application stopped working with error stating "Sorry, something went wrong. You may want to try again".

但是,仍然可以保存邮件(到草稿文件夹)并使电子邮件显示在新邮件(Outlook)对话框中.

However, the saving of the mail (to the draft folder) and getting the email being displayed in a new mail (Outlook) dialog, still works.

我正在使用Windows 10 Enterprise(版本20H2,内部版本19042.662)和Outlook 365(版本2011,内部版本13426.20308).

I'm using Windows 10 Enterprise (Version 20H2 Build 19042.662) and Outlook 365 (Version 2011 Build 13426.20308).

任何人都可以解释为什么Outlook 365 Send方法的行为与以前的Outlook版本相比有所不同.

Can anyone please explain why Outlook 365 Send method behaves different as compared to the previous Outlook versions.

这里是代码摘录.完整的示例项目可以下载.

Here is an excerpt from the code. The full sample project can be downloaded here.

internal void Send(string to, string subject, string message, OutlookActionType actionType)
        {
            _mail = _app.CreateItem(OlItemType.olMailItem);
            _namespace.Logon(null, null, true);

            _mail.To = to;
            _mail.Subject = subject;
            _mail.BodyFormat = OlBodyFormat.olFormatHTML;

            if (actionType == OutlookActionType.Send)
            {
                _mail.SaveSentMessageFolder = _namespace.GetDefaultFolder(OlDefaultFolders.olFolderSentMail);
                _inspector = _mail.GetInspector; // This ensures signature to be added to the body of the message
                _mail.HTMLBody = message + _mail.HTMLBody;
                _mail.Send(); // this raises the exception stating "Sorry, something went wrong. You may want to try again."
            }
            else if (actionType == OutlookActionType.Display)
            {
                _mail.SaveSentMessageFolder = _namespace.GetDefaultFolder(OlDefaultFolders.olFolderDrafts);
                _inspector = _mail.GetInspector; // This ensures signature to be added to the body of the message
                _mail.HTMLBody = message + _mail.HTMLBody;
                _mail.Display(); // this works
            }
            else
            {
                _mail.SaveSentMessageFolder = _namespace.GetDefaultFolder(OlDefaultFolders.olFolderDrafts);
                _inspector = _mail.GetInspector; // This ensures signature to be added to the body of the message
                _mail.HTMLBody = message + _mail.HTMLBody;
                _mail.Save(); // this works
            }
        }

如果删除了 _mail.GetInspector 行,那么它将起作用,但是如果没有该行,签名将不会被添加到邮件中,因此这不是一个选择.

If _mail.GetInspector line is removed, then it works, but without that line, the signature doesn't get added to the message, so that is not an option.

我们非常感谢您的帮助.

Any help is highly appreciated.

推荐答案

GetInspector 不再添加签名.只有 MailItem.Display 可以.

GetInspector no longer adds the signature. Only MailItem.Display does.

请参见从Excel VBA将签名插入Outlook电子邮件

这篇关于从自定义应用程序以编程方式发送电子邮件已停止使用最新的Outlook 365更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆