Outlook Addin在脱机模式下访问Exchange收件人?

问题描述:

我使用VS 2008和C#创建Outlook插件。为了实现这个功能,这个插件使用Redemption通过所有的电子邮件并解析它。Outlook Addin在脱机模式下访问Exchange收件人?

我最近遇到了没有网络连接(网络脱机,拔出,或者像笔记本电脑一样移动且当时没有连接的情况下)开启outlook的问题。它似乎在获取收件人列表。

/// <summary> 
    /// Retrieves a list of recipient addresses from an RDOMail object 
    /// </summary> 
    /// <param name="rdoItem">The email to analyze</param> 
    /// <returns>A list of e-mail addresses</returns> 
    protected List<string> GetRecipients(RDOMail rdoItem) 
    { 
     RDORecipients recipients = rdoItem.Recipients; 
     List<string> recipientList = new List<string>(); 
     if (recipients != null && recipients.Count > 0) 
     { 
      for (int i = 1; i <= recipients.Count; i++) 
      { 
       RDOAddressEntry addressEntry = recipients[i].AddressEntry; 
       if (addressEntry != null) 
       { 
        string recipient = addressEntry.SMTPAddress; 
        recipient = recipient.Trim(); 
        if (recipient != null && recipient != String.Empty) 
        { 
         recipientList.Add(recipient); 
        } 

        System.Runtime.InteropServices.Marshal.FinalReleaseComObject(addressEntry); 
        addressEntry = null; 
       } 
      } 
     } 

     if (recipients != null) 
     { 
      System.Runtime.InteropServices.Marshal.FinalReleaseComObject(recipients); 
      recipients = null; 
     } 

     return recipientList; 
    } 

所以现在的问题是,我该如何得到一个电子邮件的收件人,而无需身份验证或从Exchange解决它死去,因为:

 
    System.Runtime.InteropServices.COMException (0x80040115): Error in IAddrBook::OpenEntry: MAPI_E_NETWORK_ERROR 
    Error: The connection to Microsoft Exchange is unavailable. Your network adapter does not have a default gateway. 
    Component: Microsoft Exchange Address Book 
     at Redemption.RDOAddressEntryClass.get_SMTPAddress() 

这是该代码内发生没有网络连接?

编辑:或者 - 有没有办法在outlook中缓存smtp电子邮件地址,以便如果它以后脱机它不需要解析电子邮件地址?

+0

您是否尝试在缓存模式下使用Outlook? – 2009-10-05 04:03:32

+0

我试图不以此作为假设并找到解决方法。 – McAden 2009-10-05 18:37:47

我相信一些商店提供商是基于PST商店的包装。因此,当访问某些属性时,提供者将尝试与远程服务器进行同步。您应该能够通过从供应商处打开商店来阻止此问题。

注意:例如,向打开的商店添加项目不应将该更改保留在服务器上(例如对于IMAP4)。

了解更多关于这里的UnwrapStore财产在Redemption website

在大多数情况下PR_SMTP_ADDRESS属性应该在目的地表可用。您可以使用RDORecipient.Fields []访问该属性 - 没有理由使用RDORecipient.AddressEntry(这会导致Redemption调用IAddrbook :: OpenEntry,并且在脱机模式下调用可能会失败)。

查看收件人表OutlookSpy(单击IMessage,转到GetRecipientTable选项卡)以确保PR_SMTP_ADDRESS属性存在。

+0

我可以确认这不适用于Exchange。 – 2014-10-08 20:59:00

+0

您使用的是哪个版本的Outlook和Exchange? – 2014-10-09 14:49:22