K_M
K_M

Reputation: 386

How to use Redemption to open an Exchange shared mailbox sent folder and display it

I'm attempting to use Redemption to display an Exchange shared mailbox sent folder.

For instance I can open the inbox, contacts, or calendar folder without Redemption as follows.

Outlook.Application app = new Outlook.Application();
Outlook.NameSpace ns = app.GetNamespace("MAPI");
string recipientName = "[email protected]";
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();
}

But since olFolderSentMail cannot be specified as an argument I'm attempting to use Redemption to display the sent folder. Reference- https://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook._namespace.getshareddefaultfolder.aspx

So here's the code I'm attempting but I can't figure out how to .Display(); the folder using Redemption or if it's even possible.

Outlook.Application app = new Outlook.Application();
Outlook.NameSpace ns = app.GetNamespace("MAPI");
string recipientName = "[email protected]";
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
 }

Update: Dmity was correct but I still needed Redemption get the entryid and storeid for the Sent shared mailbox folder because I could not retrieve it using the _NameSpace.GetSharedDefaultFolder. Here's what I ended up doing, hopefully it helps someone else.

Outlook.Application app = new Outlook.Application();
Outlook.NameSpace ns = app.GetNamespace("MAPI");
string recipientName = "[email protected]";        
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();
  }        

Upvotes: 0

Views: 543

Answers (1)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66255

Folders are displayed by Outlook, there is no pure MAPI API for that. You can reopen the folder in OOM using Namespace.GetFolderFromID, then call MAPIFolder.Display.

Upvotes: 1

Related Questions