none
Search the email message parent item RRS feed

  • Question

  • Hi,

    I try to search the email message parent item, but not correct the conversationindex - if i have a very older mail item with the same subject - then the result come back the wron parent item.
    I dont understand what could be a good solution
    My code snippset:

                Outlook.Folder inboxF = Globals.ThisAddIn.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox) as Outlook.Folder; 
                string sourceIndex = mailItem.ConversationIndex.Subs tring(0, 44); 
                string topicFilter = string.Format("[ConversationTopic] = '{0}'", mailItem.ConversationTopic); 
     
                Outlook.Items topicItems = inboxF.Items.Restrict(topicFilter); 
                object item = topicItems.GetFirst(); 
     
                if (item is Outlook.MailItem) 
                { 
                    parentItem = item as Outlook.MailItem;
                } ....

    tried another code, but it did not help:

                Outlook.MailItem mItem = null; 
                Outlook.Application olApp = Globals.ThisAddIn.Application; 
                Outlook.NameSpace outlookNS = olApp.GetNamespace("MAPI"); 
                try 
                { 
                    Outlook.Folder inboxF = Globals.ThisAddIn.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox) as Outlook.Folder; 
     
                    string childIndex = mailItem.ConversationIndex.Subs tring(mailItem.ConversationIndex.Length); 
     
                    string findTopic = string.Format(@"[ConversationTopic] = {0}{1}{2}", (char)44, mailItem.ConversationTopic, (char)44); 
                    Microsoft.Office.Interop.Outlook.Items mailItems = inboxF.Items.Restrict(findTopic); 
     
                    foreach (Outlook.MailItem item in mailItems) 
                    { 
                        string parentIndex = item.ConversationIndex.Subs tring(item.ConversationIndex.Length - 10); 
     
                        if (childIndex == parentIndex) 
                        { 
                            mItem = item; 
                            break; 
                        } 
                    } 
                } 
                catch 
                { 
                } 

    Please help!

    Thanks,

    Mykie

    Friday, July 19, 2013 11:20 AM

Answers

  • The code is subtracting 10 characters from the parent index and comparing it to the child index for equality. Shouldn't that be reversed?

    Subtract 10 characters from the child item to find the comparison string for the parent, which will have one time/date stamp fewer in the index than the child item has.


    Ken Slovak MVP - Outlook

    • Marked as answer by Mykie89 Monday, July 29, 2013 2:18 PM
    Monday, July 29, 2013 1:57 PM
    Moderator

All replies

  • what do you mean by parent item of mail? first mail that started the thread?
    Friday, July 19, 2013 1:13 PM
  • yes, first mail that started the thread
    Friday, July 19, 2013 1:40 PM
  • Can anyone help me?
    Monday, July 29, 2013 7:05 AM
  • The code is subtracting 10 characters from the parent index and comparing it to the child index for equality. Shouldn't that be reversed?

    Subtract 10 characters from the child item to find the comparison string for the parent, which will have one time/date stamp fewer in the index than the child item has.


    Ken Slovak MVP - Outlook

    • Marked as answer by Mykie89 Monday, July 29, 2013 2:18 PM
    Monday, July 29, 2013 1:57 PM
    Moderator
  • Thank you!
    Monday, July 29, 2013 2:20 PM