none
PR_INTERNET_MESSAGE_ID missing sometimes for Sent items RRS feed

  • Question

  • Hi

    we have Exchange 2010 and I'm using the PR_INTERNET_MESSAGE_ID MAPI property for naming the msg files when saving them to the external database. For received items it's ok, they all have this property. But items in the SentItems folder sometimes have it and sometimes it's missing. What is interesting, that after some time the property  usually appears also for the items previously missing it.

    What is the logic for it?

    Isn't there any change how to ensure this property - call some method etc. 

    Thanks

    Filip



    Tuesday, April 23, 2013 8:48 AM

Answers

  • Is turning the cached mode off an option?

    You can also try to reopen the message from the Sent Items folder in the online mode (directly from the server) instead of using the cached copy.

    If you look at the message that does not have the message id in the cached profile and look at it in an online profile, do you see the message id in OutlookSpy or MFCMAPI?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    • Marked as answer by Filip Mateasko Wednesday, April 24, 2013 1:54 PM
    Tuesday, April 23, 2013 12:42 PM
  • You can use MAPI or Redemption to do that:

    RDOMail= RDOSession.GetMessageFromID(MessageEntryID, StoreEntryID, MAPI_NO_CACHE | MAPI_BEST_ACCESS);
     


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    • Marked as answer by Filip Mateasko Wednesday, April 24, 2013 1:53 PM
    Tuesday, April 23, 2013 1:39 PM

All replies

  • this property is generated by mail server when sending mail - so it cannot be grabbed for mails that are about to be sent.
    Tuesday, April 23, 2013 9:42 AM
  • But I'm not talking about the Outbox, I'm talking about Sent Items - they are already sent
    Tuesday, April 23, 2013 10:13 AM
  • what is in sent items is just a copy of mail that transport provider sent over to mail server - nothing more, nothing less, just a copy.
    Tuesday, April 23, 2013 10:55 AM
  • ok. so why most of the items there contains the InternetID? why it appears later when I send the item? is it possible to check it at the server somehow?
    Tuesday, April 23, 2013 10:57 AM
  • apparently it get synchronized from server, but i do not recall such thing on Exchange 2007 so most probably it was introduced in later Exchange versions, but i may be wrong. As for reading this value you would have to be creative, for example append bcc address and use EWS to that special mailbox from your add-in to read that messageid from inbox there.

    Tuesday, April 23, 2013 11:28 AM
  • :-) wow, thats a good idea - but I'm not sure if a thousand of our corporate users wouldn't be angry if they found that I deliberately infected their mails by and invisible BCC and that they send all their mail also to this address ;-) Expecially CFO could be sensitive to this, don't you think? Some safer (for me) idea? I need my job! ;-)


    however,  we are talking now about the Exchange 2010 version, not 2007 - anybody else could help? Anybody else know how it works in 2010 version?

    Tuesday, April 23, 2013 11:45 AM
  • try asking on Exchange forum or maybe switch to field that you have available on client in all situations
    Tuesday, April 23, 2013 12:01 PM
  • hmm, it has been a very long way for me to find that there exists this ID representing the message unique identificator. do you have some idea what other property could be used to create unique name for the mail item stored in the database (meaning if I upload mail item from my Sent items and Boby uploads it from his Inbox, where he maybe changed categories or flags,  the server mst be able recognize these 2 mails as duplicates and one should be removed... I tried a combination of subject, sentOn, sender etc... and then I've met a situation when out licensing server created in one moment many almost identical messages with the same sent time, sender, recipient, subject, .. and the only difference has been the different license number somewhere inside the pdf attachment. And what now? I had very complicated duplicates detection, however there were always some exceptions. So I need some absolutelly unique ID and this is (I've thought) only the InternetID. But if you had any other idea I'd be happy to know it
    Tuesday, April 23, 2013 12:15 PM
  • Is turning the cached mode off an option?

    You can also try to reopen the message from the Sent Items folder in the online mode (directly from the server) instead of using the cached copy.

    If you look at the message that does not have the message id in the cached profile and look at it in an online profile, do you see the message id in OutlookSpy or MFCMAPI?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    • Marked as answer by Filip Mateasko Wednesday, April 24, 2013 1:54 PM
    Tuesday, April 23, 2013 12:42 PM
  • Hi Dmitri, nice to meet you here!

    Well, you are right, if I switch off the cached mode, it works. However I'm not sure I can do that ( I think we need to have cached mode) . How could I reopen the message from the Sent Items folder directly from server?

    Tuesday, April 23, 2013 1:27 PM
  • You can use MAPI or Redemption to do that:

    RDOMail= RDOSession.GetMessageFromID(MessageEntryID, StoreEntryID, MAPI_NO_CACHE | MAPI_BEST_ACCESS);
     


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    • Marked as answer by Filip Mateasko Wednesday, April 24, 2013 1:53 PM
    Tuesday, April 23, 2013 1:39 PM
  • Sorry Dmitri, how to write it in C#

    this is not correct, isn't it?

                    var StoreEntryID = session.Stores.DefaultStore.EntryID;
                    var MAPI_NO_CACHE = 0x200;
                    var MAPI_BEST_ACCESS = 0x10;
     
                    i = session.GetMessageFromID(entryID, StoreEntryID, MAPI_NO_CACHE | MAPI_BEST_ACCESS);

    Tuesday, April 23, 2013 2:18 PM
  • That looks right. Do you get an error when you run it?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Tuesday, April 23, 2013 2:23 PM
  • yes - Error in IMsgStore.OpenEntry: MAPI_E_NOT_FOUND
    Tuesday, April 23, 2013 2:31 PM
  • this is my full code (maybe there is also a better way for creating RDOMail from object OutlookItem)

            public static RDOMailItem FromOutlookItem(RDOSession session, object OutlookItem,bool avoidCachedMode = false)
            {
                string entryID = string.Empty;
                if (!(OutlookItem is Outlook.MailItem || OutlookItem is Outlook.PostItem || OutlookItem is Outlook.TaskItem ||
                   OutlookItem is Outlook.SharingItem || OutlookItem is Outlook.MeetingItem || OutlookItem is Outlook.ReportItem))
                {
                    Type t = OutlookItem.GetType();
                    string subject = (string)t.InvokeMember("Subject", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.GetProperty, null, OutlookItem, null);
     
                    throw new UnsupportedItemTypeException(String.Format(Dhi.Project.Sharelook.Localization.Strings.ItemIsNotMailTaskPost, subject), subject);
                }
     
                if (OutlookItem is Outlook.MailItem) entryID = (OutlookItem as Outlook.MailItem).EntryID;
                else if (OutlookItem is Outlook.PostItem) entryID = (OutlookItem as Outlook.PostItem).EntryID;
                else if (OutlookItem is Outlook.TaskItem) entryID = (OutlookItem as Outlook.TaskItem).EntryID;
                else if (OutlookItem is Outlook.SharingItem) entryID = (OutlookItem as Outlook.SharingItem).EntryID;
                else if (OutlookItem is Outlook.MeetingItem) entryID = (OutlookItem as Outlook.MeetingItem).EntryID;
                else if (OutlookItem is Outlook.ReportItem) entryID = (OutlookItem as Outlook.ReportItem).EntryID;
     
                RDOMail i;
                if (!avoidCachedMode)
                {
                    i = session.GetMessageFromID(entryID); //this works so the EntryID should be OK
                }
                else
                {
                    var StoreEntryID = session.Stores.DefaultStore.EntryID;
                    var  MAPI_NO_CACHE = 0x200;
                    var MAPI_BEST_ACCESS = 0x10;
     
                    try
                    {
                        i = session.GetMessageFromID(entryID, StoreEntryID, MAPI_NO_CACHE | MAPI_BEST_ACCESS);
     
                    }
                    catch (Exception ex)
                    {
                        var a = ex;
                        return null;
                    }
                }
     
                RDOMailItem newItem = new RDOMailItem(i, session);
                newItem.CheckOrCreateSharepointPath("");
                return newItem;
            }

    Tuesday, April 23, 2013 2:37 PM
  • That most likely means the message only exist in your cached store and has not yet been uploaded to the server.

    Do you run that code immediately after the message is sent?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Tuesday, April 23, 2013 7:30 PM
  • yes, the code is fired by the ItemAdd event on SentItems folder. this function should upload the message when it's sent.
    Wednesday, April 24, 2013 6:59 AM
  • It will not. The message is uploaded later when the cached store provider decide to sync the Sent Items folder.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Wednesday, April 24, 2013 7:03 AM
  • I meant my function - its purpose is to upload message to the Sahrepoint when it's sent. ok. Am I somehow able to detect the moment when the message is really sent - meaning when the cached store provider decide to sync the Sent Items folder?

    Wednesday, April 24, 2013 7:06 AM
  • So finally I've found a solution - I repeatedly call the server and try to get the message from there using your suggested method. I takes some time, however, when the "item" is retrieved from the server, it contains the InternetID and everything work perfectly.

    So many thanks Dmitri, you helped me (again) very much. !!

    Wednesday, April 24, 2013 1:53 PM