如何使用Redemption打开Exchange共享邮箱发送文件夹并显示它

时间:2016-12-04 20:37:29

标签: outlook-addin outlook-redemption

我尝试使用Redemption来显示Exchange共享邮箱发送文件夹。

例如,我可以在没有兑换的情况下打开收件箱,联系人或日历文件夹,如下所示。

Outlook.Application app = new Outlook.Application();
Outlook.NameSpace ns = app.GetNamespace("MAPI");
string recipientName = "SharedAccountName@MyCompany.com";
Outlook.Recipient recip = ns.CreateRecipient(recipientName);
recip.Resolve();

if (recip.Resolved)
{
  Outlook.MAPIFolder InboxFolder = ns.GetSharedDefaultFolder(recip, Outlook.OlDefaultFolders.olFolderInbox);
  //Outlook.MAPIFolder ContactsFolder = ns.GetSharedDefaultFolder(recip, Outlook.OlDefaultFolders.olFolderContacts);
  //Outlook.MAPIFolder CalendarFolder = ns.GetSharedDefaultFolder(recip, Outlook.OlDefaultFolders.olFolderCalendar);
  InboxFolder.Display();
}

但由于olFolderSentMail无法指定为参数,因此我尝试使用Redemption来显示已发送的文件夹。参考-  https://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook._namespace.getshareddefaultfolder.aspx

所以这里是我尝试过的代码,但我无法弄清楚如何使用.Display();使用Redemption的文件夹,或者甚至是可能的。

Outlook.Application app = new Outlook.Application();
Outlook.NameSpace ns = app.GetNamespace("MAPI");
string recipientName = "SharedAccountName@MyCompany.com";
Outlook.Recipient recip = ns.CreateRecipient(recipientName);
recip.Resolve();

Redemption.RDOSession session = new Redemption.RDOSession();
session.MAPIOBJECT = Application.Session.MAPIOBJECT;

if (recip.Resolved)
 {
   Redemption.RDOFolder Sentfolder = session.GetSharedDefaultFolder(recip, rdoDefaultFolders.olFolderSentMail);
   Sentfolder. // There's no Intellisense for Display
 }

更新:Dmity是正确的,但我仍然需要Redemption获取Sent共享邮箱文件夹的entryid和storeid,因为我无法使用_NameSpace.GetSharedDefaultFolder检索它。这就是我最终做的事情,希望它可以帮助其他人。

Outlook.Application app = new Outlook.Application();
Outlook.NameSpace ns = app.GetNamespace("MAPI");
string recipientName = "anExchangeEmailAddress@yourCompany.com";        
Outlook.Recipient recip = ns.CreateRecipient(recipientName);
recip.Resolve();
Redemption.RDOSession session = new Redemption.RDOSession();
session.MAPIOBJECT = Application.Session.MAPIOBJECT;

 if (recip.Resolved)
  {
    Redemption.RDOFolder Sentfolder = session.GetSharedDefaultFolder(recip, rdoDefaultFolders.olFolderSentMail);
    string folderID = Sentfolder.EntryID;
    string storeID = Sentfolder.StoreID;
    Outlook.MAPIFolder displaySent = ns.GetFolderFromID(folderID, storeID);
    displaySent.Display();
  }        

1 个答案:

答案 0 :(得分:1)

Outlook显示文件夹,没有纯MAPI API。您可以使用Namespace.GetFolderFromID在OOM中重新打开该文件夹,然后调用MAPIFolder.Display