2

We are building sort of Communication Management System atop Outlook. One of the important task we wish to achieve is to retrieve all the messages (.msg files??) in the same thread along with their attachments and put them in the same folder inside CMS's repository .

The problem we are facing is how do we know programatically that particular message (or .msg file??) and attachment belongs to the particular thread.

Say for a first message we create a folder in a repository. Then we want all the messages (along with attachments) sent as a reply to the original message to go automatically in the same folder.

I tried to find if their is any header set in .msg file to identify the thread, but did not found anything.

But still curious how the Outlook client can show the messages arranged as communication thread hierarchy. So there must be some way that we can retrieve this information stored somewhere. I just want to know how can I access it.

Mahesha999
  • 22,693
  • 29
  • 116
  • 189
  • I believe Outlook uses the text in message Subject to group emails to conversations. As it grouped non-relevant emails together with blank subject emails in my Outlook 2010. – PatricK Aug 21 '13 at 06:42
  • so u mean if we change the subject line while writing the reply it will not group that particular reply under the same thread? – Mahesha999 Aug 21 '13 at 06:50
  • It didn't group when I reply with change of subject text. But when I change back the subject of the changed reply, it didn't group it back to the first one. The logic may be if current subject is different to subject in the replied, it will treat it as new conservation. – PatricK Aug 21 '13 at 07:06
  • You might have better luck to compare the "References:", "In-Reply-To:" strings in Message Option (internet header) with "Message-ID:", the grouped emails have the Message-ID of the first email as References. References can be multiple lines. – PatricK Aug 21 '13 at 07:25

2 Answers2

2

The grouped conservation are indicated in the message header: "Message-ID: ", "References: " & "In-Reply-To: ", you can view it with Outlook VBA with below function I found previously.

Private Function GetInetHeaders(olkMsg As Outlook.MailItem) As String
    ' Purpose: Returns the internet headers of a message.'
    ' Written: 4/28/2009'
    ' Author:  BlueDevilFan'
    ' Outlook: 2007'
    Const PR_TRANSPORT_MESSAGE_HEADERS = "http://schemas.microsoft.com/mapi/proptag/0x007D001E"
    Dim olkPA As Outlook.PropertyAccessor
    Set olkPA = olkMsg.PropertyAccessor
    GetInetHeaders = olkPA.GetProperty(PR_TRANSPORT_MESSAGE_HEADERS)
    Set olkPA = Nothing
End Function
PatricK
  • 6,375
  • 1
  • 21
  • 25
0

Use PR_CONVERSATION_INDEX property (you can see it in OutlookSpy (I am its author) if you click the IMessage button)
Conversation tracking is documented on MSDN: http://msdn.microsoft.com/en-us/library/office/cc765583.aspx

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • Hey hi sorry for late response I was fiddling with what u have pointed me to, and it seems to work. However can you just explain where this `PR_CONVERSATION_INDEX` is stored? In `.msg` file? On exchange server/ Outlook client? Just want to know if I can access this same property using some Java library. – Mahesha999 Aug 28 '13 at 10:40
  • PR_CONVERSATION_INDEX is one of the MAPI properties. You can see it in OutlookSpy (http://www.dimastr.com/outspy) - click IMessage button. – Dmitry Streblechenko Aug 29 '13 at 16:37
  • So its not stored in `.msg` file? Or in some Outlook encrypted file? or in exchange server? I might be sounding stupid here. But **really want to know about physical storage not just about how to access it**. Also am new to MAPI so dont know where these MAPI properties are actually stored & fetched from...... – Mahesha999 Aug 31 '13 at 12:43
  • ......Also [this](http://msdn.microsoft.com/en-us/library/cc765570.aspx) says, `Properties can be persistent or temporary. Properties that persist from session to session can be stored with their objects' data or in the profile. Temporary properties exist only for the duration of the current session.` But this didnt make any sense `objects' data` means `.msg` files for mail objects? – Mahesha999 Aug 31 '13 at 12:44
  • 1
    Outlook does not know or care where or how the messages and their properties are stores. Each store provider is obviously different, and you can write your own store provider that Outlook will be happy to use if you expose all the required interfaces. – Dmitry Streblechenko Aug 31 '13 at 16:41
  • Ohkay am new to this MAPI-thingy. So just want another confirmation. By store provider do you mean MAPI Message Store Provider? And does [this](http://msdn.microsoft.com/en-us/library/cc842153.aspx) page talks about developing the same? – Mahesha999 Sep 02 '13 at 08:41
  • Yes that is exactly what I mean. Why do you care about the actual physical storage? Is there a particular problem you are trying to solve? – Dmitry Streblechenko Sep 03 '13 at 16:20
  • hey sorry to take ur attention this way but can u just see [this](http://stackoverflow.com/questions/19022128/automatically-moving-all-mails-belonging-to-same-conversation-thread-to-external) related question; the reason I want the physical storage of `PR_CONVERSATION_INDEX` is that I want to retrieve `PR_CONVERSATION_INDEX ` through Java, but without using `EWS` since there are no MS supported Java API for `EWS`, if it is stored in `.msg` file I can use `Apache POI` like file reading Java API to retrieve `PR_CONVERSATION_INDEX` – Mahesha999 Sep 26 '13 at 11:22
  • EWS is all about making HTTP calls and creating and retrieving XML data. Why do you need a special Java API for that? What does EWS have to do with MSG files? Neither Exchange not Outlook store their data as MSG files (but you can export a particular message as an MSG file). – Dmitry Streblechenko Sep 26 '13 at 16:39
  • So if I export a message as an MSG file will Conversation Index be encapsulated in it. I think I tried this once by giving MSG file as an input to [Apache POI](http://poi.apache.org/hsmf/), but I didnt found any field like Conversation Index in it. So I binary parsed the file and output as char string and still I didnt found any Conversation Id in it, though I found MessageId. **So just want to be sure if Conversation Id is encapsulated in MSG file just to give reading MSG file another shot.** – Mahesha999 Sep 27 '13 at 08:29
  • You can check for yourself using OutlookSpy (http://www.dimastr.com/outspy - I am its author) - click OpenIMsgOnIStg button to open an MSG file and look at its properties. – Dmitry Streblechenko Sep 30 '13 at 14:38