2017-01-16 81 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