如何使用 Redemption 打开 Exchange 共享邮箱的已发送文件夹并显示它
How to use Redemption to open an Exchange shared mailbox sent folder and display it
我正在尝试使用 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 获取已发送共享邮箱文件夹的 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();
}
文件夹由Outlook显示,没有纯MAPI API。您可以使用 Namespace.GetFolderFromID
在 OOM 中重新打开文件夹,然后调用 MAPIFolder.Display
。
我正在尝试使用 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 获取已发送共享邮箱文件夹的 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();
}
文件夹由Outlook显示,没有纯MAPI API。您可以使用 Namespace.GetFolderFromID
在 OOM 中重新打开文件夹,然后调用 MAPIFolder.Display
。