How to find the relation between first mail and reply/forward mail while reading mails.

0 votes
asked Nov 19, 2014 by posham (160 points)
edited Nov 21, 2014

Hi,

We are reading mails from mail server using Rebex mail tool, are there any ways to get to know reply/forward mail is related to this first mail. Ex: I sent an email to x.mail.com id and later x.mail.com reply/forward mail to my email id. while reading both mails how do we know this is the reply mail of previous mail.

Are there any reference id which will carry with each mail message?

Thank you in advance. shekhar.

Applies to: Rebex Secure Mail

3 Answers

0 votes
answered Nov 20, 2014 by Tomas Knopp (58,890 points)
edited Nov 20, 2014

There are three properties which could be used for the task, namely MessageId, InReplyTo and the References header. See the RFC822 and RFC2822 for documentation.

Retrieving these from the MailMessage can be done like this:

MailMessage mail;
// ...
MessageId id = mail.MessageId;

MessageIdCollection inReplyTo = mail.InReplyTo;
MessageIdCollection references = mail.ToMimeMessage().References;

With the help of the above you will be able to assemble the graph together.

0 votes
answered Nov 20, 2014 by posham (160 points)
edited Nov 20, 2014

Thank you for your suggestion,

I have verified this mail.InReplyTo and mail.References properties, this is working fine with Gmail but with yahoo (like yahoo to yahoo or yahoo to gmail) the references are not maintaining. Ex:

First mail Message-ID # <1687342428.837462.1416303027597.JavaMail.yahoo@jws10954.mail.sg3.yahoo.com>

Next Reply Mail:

Message-ID # <1702028209.837955.1416303255394.JavaMail.yahoo@jws10939.mail.sg3.yahoo.com>
In-Reply-To # <314035792.840956.1416303231163.JavaMail.yahoo@jws10943.mail.sg3.yahoo.com>
References # <314035792.840956.1416303231163.JavaMail.yahoo@jws10943.mail.sg3.yahoo.com>

Would you please help on this.

Thank you posham

0 votes
answered Nov 21, 2014 by Tomas Knopp (58,890 points)
edited Nov 21, 2014

I have performed a test and for me the yahoo servers worked fine. I've tested three scenarios (I sent a new email,and then I replied to the email). Below are the MessageId and InReplyTo for each scenario:

        yahoo -> yahoo

    original message from yahoo

      subject: 'MessageId'
      message id: '<739062199.1957909.1416564116008.JavaMail.yahoo@jws11147.mail.ir2.yahoo.com>'

    reply from yahoo
      subject: 'Re: MessageId'
      message id: '<1003716917.1971053.1416564182682.JavaMail.yahoo@jws11172.mail.ir2.yahoo.com>'
      in reply to: '<739062199.1957909.1416564116008.JavaMail.yahoo@jws11147.mail.ir2.yahoo.com>'


        yahoo -> gmail -> yahoo

    original message from yahoo
      subject: 'yahoo to gmail'
      message id: '<302319435.601472.1416569838549.JavaMail.yahoo@jws11146.mail.ir2.yahoo.com>'

    reply from gmail
      subject: 'Re: yahoo to gmail'
      message id: '<cal-tjhls+jc7e+6tvsqtrl4aprd3k3hgi6vc3m1uxrgejtbehw@mail.gmail.com>'
      in reply to: '<302319435.601472.1416569838549.JavaMail.yahoo@jws11146.mail.ir2.yahoo.com>'


      gmail -> yahoo -> gmail

    original message from gmail
      subject: 'Gmail to yahooo'
      message id: '<cal-tjh+qxymd8t7x=_vzt_hlobg81zrxzm1drs6ta97+_7bfwg@mail.gmail.com>'

    reply from yahoo
      subject: 'Re: Gmail to yahooo'
      message id: '<534866945.2050889.1416571511000.JavaMail.yahoo@jws11109.mail.ir2.yahoo.com>'
      in reply to: '<cal-tjh+qxymd8t7x=_vzt_hlobg81zrxzm1drs6ta97+_7bfwg@mail.gmail.com>'

Each of the reply emails was carrying the correct InReplyTo header (it was equal to the original MessageId of the message to which I replied).

...