I have an issue with sentfolder EntryId from Outlook.
I work with sentfolder
I have 2 Accounts. My account (dafault(Exchange)): all works perfect.
The second account(additional(Exchange)) has:
outboxMailEntryID = 00000000A24FEAFFFFB93C47A13126365D132558010010E2685A8E0AC440B14F77F5EE5275A5000000BBA**800000**0
sentMailEntryID = 00000000A24FEAFFFFB93C47A13126365D132558010010E2685A8E0AC440B14F77F5EE5275A5000000BBA7FF0000
At runtime the sendfolder get an other EntryId. It changes
from:
IsOutputExtended check folder.Name = **Gesendete Elemente** folder.EntryID = 00000000A24FEAFFFFB93C47A13126365D132558018010E2685A8E0AC440B14F77F5EE5275A5000000BBA**8000000**
to:
IsOutputExtended check folder.Name = **Gesendete Elemente** folder.EntryID = 00000000A24FEAFFFFB93C47A13126365D132558018010E2685A8E0AC440B14F77F5EE5275A5000000BBA**8000100**
I do follows:
private static bool IsOutputExtended(MAPIFolder currentFolder)
{
PropertyAccessor propAcc = null;
Microsoft.Office.Interop.Outlook.Folders folders = null;
MAPIFolder rootFlder = null;
Store store = null;
if(currentFolder == null)
return false;
try
{
store = currentFolder.Store;
const string PR_IPM_OUTBOX_ENTRYID = "http://schemas.microsoft.com/mapi/proptag/0x35E40102";
const string PR_IPM_SENTMAIL_ENTRYID = "http://schemas.microsoft.com/mapi/proptag/0x35E20102";
rootFlder = store?.GetRootFolder();
folders = rootFlder?.Folders;
string sentMailEntryID = "";
string outboxMailEntryID = "";
propAcc = store?.PropertyAccessor;
try
{
if (propAcc != null)
{
object entryOutbox = propAcc.GetProperty(PR_IPM_OUTBOX_ENTRYID);
outboxMailEntryID = propAcc.BinaryToString(entryOutbox);
object entrySend = propAcc.GetProperty(PR_IPM_SENTMAIL_ENTRYID);
sentMailEntryID = propAcc.BinaryToString(entrySend);
}
}
catch(Exception ex)
{
CobraMain.Logger.Warn("Error in IsOutputExtended by Check PR_IPM_OUTBOX_ENTRYID and PR_IPM_SENTMAIL_ENTRYID for " currentFolder.Name, ex);
}
if(currentFolder.EntryID == sentMailEntryID || currentFolder.EntryID == outboxMailEntryID)
return true;
....
Have someone an idea what happens?
Thanks.
CodePudding user response:
Don't keep the EntryID
property value in the code. Instead, use the GetDefaultFolder method of the Store
class which returns a Folder
object that represents the default folder in the store and that is of the type specified by the FolderType
argument. This method is similar to the GetDefaultFolder
method of the NameSpace
object. The difference is that this method gets the default folder on the delivery store that is associated with the account, whereas NameSpace.GetDefaultFolder
returns the default folder on the default store for the current profile.
CodePudding user response:
You should always treat entry ids as black boxes. Never compare entry ids directly, always use Namespace.CompareEntryIDs
.
Keep in mind that multiple entry ids can refer to the same MAPI object. The MAPI provider is free to store whatever it deems necessary inside its entry ids, including flags that can depending on how the object was opened.