【问题标题】:Cannot send displayed email using redemption in c#无法使用 C# 中的兑换发送显示的电子邮件
【发布时间】:2011-07-08 23:54:11
【问题描述】:

我在 C# 中使用 Redemption-Data-Objects 创建了一个新的电子邮件消息。调用 Display() 后,窗口打开 - 一切看起来都很棒。

当我尝试发送消息时,通过单击“发送”按钮,我收到以下消息之一(从德语翻译...):“消息接口返回未知错误。尝试重新启动 Outlook如果问题......”或“无法发送元素!”

当我使用发送方法时,一切正常,电子邮件将被发送。

我尝试 OutlookSpy 来寻找解决方案 - 当我尝试发送消息时,我得到返回码 0x80020009。

这里是示例代码:

Redemption.RDOSession session = new Redemption.RDOSession();
session.Logon(null, null, false, null, null, null);
Redemption.RDOFolder folder = session.GetDefaultFolder(Redemption.rdoDefaultFolders.olFolderOutbox);
Redemption.RDOMail newMail = folder.Items.Add(Redemption.rdoItemType.olMailItem);

// no difference when using .Add
newMail.Recipients.AddEx("a.b@blabla.com","a.b@blabla.com", "SMTP", Redemption.rdoMailRecipientType.olTo);
newMail.Recipients.ResolveAll();
newMail.Subject = "Testmail-Subject";
newMail.HTMLBody = "Test";
newMail.Display(false, Type.Missing);

有人知道这个问题的解决方案吗?

问候马丁

PS:我在 Windows 7(英语)上使用 Office 2010(德语)和 Visual Studio 2010(英语),在我的项目中使用目标框架 2.0。

【问题讨论】:

    标签: c# email send outlook-redemption


    【解决方案1】:

    好的...

    我发现了“错误”。

    由于我的会话超出范围,上下文丢失,因此发生错误。

    解决办法如下:

    // Event object to wait for
    System.Threading.ManualResetEvent _manualEvent = new ManualResetEvent(false);
    
    private void DisplayMail() {
        ...
        // register an eventhandler for the close event
        _newMail.OnClose += new Redemption.IRDOMailEvents_OnCloseEventHandler(_newMail_OnClose);
    
        _newMail.Recipients.Add(txtTo);
        _newMail.Recipients.ResolveAll();
        _newMail.Subject = subject;
        _newMail.HTMLBody = body;
    
        _newMail.Display(false, null);
        // wait here until the message-window is closed...
        _manualEvent.WaitOne();
    }
    
    private void _newMail_OnClose()
    {
        _manualEvent.Set();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-04-19
      • 2015-09-06
      • 2014-06-26
      • 2012-01-06
      • 2015-06-11
      • 2021-07-08
      • 2018-09-01
      相关资源
      最近更新 更多