2017-01-16 108 views
0

这个问题正在发生,我们的客户之一,我一直无法在我身边复制使用相同版本的Outlook。我的客户和我正在使用安装了Outlook 2016的Office 365。当他通过Outlook Redemption(用于Outlook集成的第三方程序)在我们的程序中发送电子邮件时,邮件卡在他的发件箱中。邮寄通过Outlook赎回邮寄Oulook发件箱

如果他双击消息(所以它在Outlook中弹出),他可以点击发送按钮,它会发送sucessfuly。如果他们使用旧版本的Outlook(2010),这不是问题。我当时将它们升级到最新版本的Outlook Redmeption(2016年5月7日发布),不过看起来他们几天前刚推出了新版本。我会很快尝试,但更改日志并未提及邮件卡在发件箱中。

我也注意到,在他的发件箱中的邮件有什么似乎是对他们的“草稿”的象征,而在我的发件箱中,他们对他们有“发送”符号。这似乎很重要,但我不确定我能做些什么。

此外,点击发送/接收所有文件夹不起作用。

我的代码如下。感谢您的帮助。

 public static bool SendMessage(Recipients recipients, string[] addressListReplyTo, string subject, string body, string[] attachments, bool requestReadReceipt, Log log, bool isHtmlBody = false) 
    { 
     RDOSession session = null; 
     RDOMail mail; 
     RDOFolder folder; 
     bool result = true; 

     session = GetSessionAndLogon(log); 
     if (session == null) 
      return false; 

     folder = session.GetDefaultFolder(rdoDefaultFolders.olFolderOutbox); 
     mail = folder.Items.Add(); 
     if (isHtmlBody) 
      mail.HTMLBody = body; 
     else 
      mail.Body = body; 
     mail.Subject = subject; 
     mail.ReadReceiptRequested = requestReadReceipt; 
     foreach (string attachment in attachments) 
     { 
      if (attachment != "") 
       mail.Attachments.Add(attachment); 
     } 
     foreach (string address in addressListReplyTo) 
     { 
      if (address != "") 
       mail.ReplyRecipients.Add(address); 
     } 
     foreach (string address in recipients.To) 
     { 
      if (address != "") 
       mail.Recipients.Add(address).Type = 1; 
     } 
     foreach (string address in recipients.Cc) 
     { 
      if (address != "") 
       mail.Recipients.Add(address).Type = 2; 
     } 
     foreach (string address in recipients.Bcc) 
     { 
      if (address != "") 
       mail.Recipients.Add(address).Type = 3; 
     } 

     foreach (RDORecipient recipient in mail.Recipients) 
     { 
      if (!OutlookMailEngine64.existsName(recipient.Name, session, log == null ? null : log)) 
       result = false; 
     } 
     if (result) 
     { 
      try 
      { 
       mail.Send(); 
       result = true; 
      } 
      catch (System.Runtime.InteropServices.COMException ex) 
      { 
       string message = "Error while sending email: " + ex.Message; 
       if (log != null) 
        log.Message(message); 
       if (OutlookMailEngine64.DiagnosticMode) 
        MessageBox.Show(message); 
       throw new EmailLibraryException(EmailLibraryException.ErrorType.InvalidRecipient, "One or more recipients are invalid (use OutlookMailEngine64.ValidateAddresses first)", ex); 
      } 
     } 
     if (session.LoggedOn) 
      session.Logoff(); 

     return result; 
    } 

回答

1

Dmitry通过电子邮件与我合作。对我来说,解决方案是将SafeMailItem对象的RDO换掉。这里是我的方法的更新版本,以便您可以看到更改:

private static bool SendSafeMessage(Recipients recipients, string[] addressListReplyTo, string subject, string body, string[] attachments, bool requestReadReceipt, Log log, bool isHtmlBody = false) 
    { 
     //This method was added because sometimes messages were getting stuck in the Outlook Outbox and this seems to solve that 
     bool result = true; 

     Microsoft.Office.Interop.Outlook.Application application = new Microsoft.Office.Interop.Outlook.Application(); 
     Microsoft.Office.Interop.Outlook.NameSpace namespaceMAPI = application.GetNamespace("MAPI"); 
     namespaceMAPI.Logon(); 
     RDOSession session = null; 
     session = GetSessionAndLogon(log); //TODO: I'm creating a 2nd session here which is wasteful 

     SafeMailItem safeMail = Redemption.RedemptionLoader.new_SafeMailItem(); 
     Microsoft.Office.Interop.Outlook.MailItem outlookMailItem = (Microsoft.Office.Interop.Outlook.MailItem)application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); 
     safeMail.Item = outlookMailItem; 

     if (isHtmlBody) 
      outlookMailItem.HTMLBody = body; 
     else 
      safeMail.Body = body; 
     outlookMailItem.Subject = subject; 
     outlookMailItem.ReadReceiptRequested = requestReadReceipt; 
     foreach (string attachment in attachments) 
     { 
      if (attachment != "") 
       safeMail.Attachments.Add(attachment); 
     } 
     foreach (string address in addressListReplyTo) 
     { 
      if (address != "") 
       safeMail.ReplyRecipients.Add(address); 
     } 
     foreach (string address in recipients.To) 
     { 
      if (address != "") 
       safeMail.Recipients.Add(address).Type = 1; 
     } 
     foreach (string address in recipients.Cc) 
     { 
      if (address != "") 
       safeMail.Recipients.Add(address).Type = 2; 
     } 
     foreach (string address in recipients.Bcc) 
     { 
      if (address != "") 
       safeMail.Recipients.Add(address).Type = 3; 
     } 

     foreach (Microsoft.Office.Interop.Outlook.Recipient recipient in outlookMailItem.Recipients) 
     { 
      if (!OutlookMailEngine64.existsName(recipient.Name, session, log == null ? null : log)) 
       result = false; 
     } 
     if (result) 
     { 
      try 
      { 
       safeMail.Send(); 
       result = true; 
      } 
      catch (System.Runtime.InteropServices.COMException ex) 
      { 
       string message = "Error while sending email: " + ex.Message; 
       if (log != null) 
        log.Message(message); 
       if (OutlookMailEngine64.DiagnosticMode) 
        MessageBox.Show(message); 
       throw new EmailLibraryException(EmailLibraryException.ErrorType.InvalidRecipient, "One or more recipients are invalid (use OutlookMailEngine64.ValidateAddresses first)", ex); 
      } 
     } 

     if (session.LoggedOn) 
      session.Logoff(); 

     namespaceMAPI.Logoff(); 

     return result; 
    } 
1

请记住,邮件提交是异步的,它会n要被自动触发,除非您使用的是在线Exchange存储(其中存储和传输提供紧密耦合)。

您可以强制发送/通过在Outlook对象模型调用Namespace.SendAndReceive接收。

+0

谢谢您的回复。 'Namespace.SendAndReceive'与在Outlook中手动发送和接收所有文件夹一样,是正确的吗?如果是这样,那没有帮助。我们点击了该按钮,该消息仍然位于发件箱中,并带有“草稿”图标,而不是“发送”图标。 客户还测试了最新版本的赎回(2017年1月9日),但这并没有帮助(我没有料到它,只是想更新)。 我也愿意直接与你沟通,如果这样对你更好。感谢您的帮助! – bruestle2

+1

发件箱文件夹中是否有预览窗格? Outlook是否显示斜体信息? –

+0

以下是包含发送/接收的客户屏幕截图,以显示他们不会发送。 http://i.imgur.com/rWYQSh9.png另外,事实证明我对一个细节不正确。他们正在使用Office 2016的Google App Sync,而不是Office 365。 – bruestle2