How to differentiate mail conversations using Rebex Secure Mail tool

0 votes
asked Apr 6, 2015 by shekhar (190 points)

Hi, We bought Rebex Secure mail tool 2 months back and using to read the mails from mail server.
We have a functionality to extract/get mail content from mail body.
1) While reading mail we don't need "signature" (Excluding signature from mail body).
How to exclude signature from mail body?

2) How to do Mail history cut-off functionality? Need to exclude previous mails content from mail body (mail chain/history).
How to get content of current mail?

3) hot to find webmail server source? (i.e. sender of the mail like Gmail, yahoo, hotmail etc...)

Please give solution/suggestions for above questions ASAP.

Thank you in advance.

Applies to: Rebex Secure Mail

1 Answer

0 votes
answered Apr 7, 2015 by Tomas Knopp (58,890 points)

Hello,

1) removing the signature is possible with the code below:

MailMessage mail = new MailMessage();
// load mail
    mail.Load(@"C:\temp\mail.eml");

if (mail.IsSigned)
    mail.RemoveSignature();

2) Actually when replying to an email, there are many possibilities on how to include the previous email into the reply (e.g. various possible formattings). Different email clients can use different formattings. Also imagine the old-school style - writing the reply into the previous email answering individual questions one by one - this is also perfectly legitimate and still used by some people. So the task to understand the email chain history is equal to the task of automating text comprehension which is not something that we would like to build into the Rebex Secure Mail library which is a component library for sending, receiving and parsing emails on "lower" level.

Modern email clients like Gmail try to chain the messages (we guess that they implement rules to parse the most common types of replies), however, they might have problems with unusual types of replies. This is not such a big problem because the human user can clearly see that something went wrong with the recognition and they can revert to the plain email body and ignore the failing recognition. But what would happen in a component library? No one is there to differentiate between a good and bad output.

So that is why there is no direct support for the history funcionality and we also do not plan to add this feature.
I guess you already asked us once at the forum, so to sum it up we currently do not have such feature and the task has to be programmed on top of Rebex Secure Mail by you, please see the link to the stack overflow forum post on how to implement this functionality yourself. Sorry!

3) Received headers of the email could be used to determine the orifinating server. When email gets sent every SMTP server along the way should add a Received header with information about itself. So in the last Received header you can find the first SMTP server. The only trouble I can think of is how to determine the difference between the email being sent from a browser Gmail versus email which was sent via Gmail SMTP from an SMTP client, like Rebex SMTP.

Here is the code which lists all the Received header of an incoming email. The originating server's header is the last one in the list:

var message = imap.GetMailMessage(sequenceNumber);

foreach (MimeHeader header in message.Headers)
{
    if (header.Name == "Received")
        Console.WriteLine(header);
}

Another header which you could take into account when determining the originating server is the "DKIM-Signature" header which is basically a signature used to verify that the email was actually sent by the server as is, and not by someone else.

commented Apr 9, 2015 by shekhar (190 points)
Thanks for detailed information...
regarding point
1) we are not reading the mail from .emi file, reading mail from MailEnable mailboxes. while doing this "mail.IsSigned" value is getting as FALSE... hence signature is not removing.

3) Yes, with "DKIM-Signature" header we can get actual server but the header value is getting for only GMAIL and YAHOO not for the Hotmail and iCloud.
Do we need do any thing (configuration or settings) to get "DKIM-Signature" header for hotmail and iCloud?

Will you provide any suggestions to know reading mail is a FIRST mail or Reply Mail or Forward Mail? Are there any property/attribute to get these details?

Thank you in advance.
commented Apr 9, 2015 by Tomas Knopp (58,890 points)
1) Even if you get the MailMessage via Imap.GetMailMessage or some other method, still the property should be set to 'true' for a signed email... Do you mean that the email that you are getting from the server is actually signed although the property is set to 'false'?

2) well, the DKIM-Signature header is not compulsory, so if the outgoing SMTP (be it hotmail, icloud or any other) server is not putting it into the message, we advice you to ask the server support team. There is no option in Rebex components which could make the server use this header, sorry.
commented Apr 10, 2015 by shekhar (190 points)
Will you provide any suggestions to know reading mail is a FIRST mail or Reply Mail or Forward Mail? Are there any property/attribute to get these details?
commented Apr 13, 2015 by Lukas Pokorny (93,630 points)
A *reply mail* or *forward mail* should have an `In-Reply-To` header set (to the Message-ID of the replied or forwarded mail.

Unfortunately, it's tricky to distinguish *reply mail* from *forward mail* - there is no difference in the headers, so looking for "FW:" in the subject or "Forwarded message" in the message text seems to be the only way (and an imperfect one - mail clients are not guaranteed to use these and their non-English will most likely use different texts).
...