In from field of email, your names contains double quote which shows \" instead of "

0 votes
asked Jan 17 by dsouzac (360 points)

Inbound email id is ""atul" cus't'omer" atcust@ccms.apac.avaya.com. when any email comes from this email id it shows as,

From: "\"atul\" cus't'omer" atcust@ccms.apac.avaya.com

Here is my question, how should i get ""atul" cus't'omer" atcust@ccms.apac.avaya.com instead of "\"atul\" cus't'omer" atcust@ccms.apac.avaya.com.

I am using POP3:v4.0.30319 version Rebex lib.

Please let me know how to solve it or is there any other way to skip "\" from From field.

Applies to: Rebex Secure Mail
commented Jan 17 by dsouzac (360 points)
Is this an issue in Rebex?

1 Answer

0 votes
answered Jan 17 by Lukas Pokorny (85,590 points)
selected Jan 17 by dsouzac
 
Best answer

This From header is not formatted correctly:

From: "\"atul\" cus't'omer" atcust@ccms.apac.avaya.com

According to RFC 2822, the address must be enclosed in angle brackets when display name is present, which means the header should look like this:

From: "\"atul\" cus't'omer" <atcust@ccms.apac.avaya.com>.

Please note that \" is not causing any problems - the backslash just indicates that the following character is a literal character, not a control character. The lack of < and > is the problem. (See the examples in RFC 2822.)

commented Jan 17 by dsouzac (360 points)
Thanks for quick reply, but you got it wrong. My issue is with display name, while typing i have typed angle brackets but it didn't shown when i published my question.

its ok, here again..
display name: "atul" cus't'omer
address: atcust@ccms.apac.avaya.com

so email id looks like "atul" cus't'omer <atcust@ccms.apac.avaya.com>. When i send an email from this email id (e.g. outlook or thunderbird or etc) to my email id which is configured in my application and implemented by Rebex library.

in this scenario, i display from email id e.g. msg.From (msg is MailMessage object). then it shows as "\"atul\" cus't'omer" <atcust@ccms.apac.avaya.com>, where as I am expecting it to be displayed as "atul" cus't'omer <atcust@ccms.apac.avaya.com>.

Actual Result:"\"atul\" cus't'omer" <atcust@ccms.apac.avaya.com>
Expected result: "atul" cus't'omer <atcust@ccms.apac.avaya.com>
commented Jan 17 by Lukas Pokorny (85,590 points)
Oh well, sorry for the confusion. It looks like you use .ToString() to display the content of msg.From, but this results in an encoded form of the display name - it returns the contents of the header, not its visual representation. However, decoded parts are available through MailAddress object, which makes it quite simple to achieve what you need - just cunstruct the desired visual representation yourself.

This code displays the name and address parts along with ToString() and a custom-formatted form, which looks like what you need:

        foreach (MailAddress address in mail.From)
        {
            Console.WriteLine("Name: {0}", address.DisplayName);
            Console.WriteLine("Address: {0}", address.Address);
            Console.WriteLine("Both: {0}", address.ToString());
            Console.WriteLine("Custom: {0} <{1}>", address.DisplayName, address.Address);
        }
commented Jan 17 by dsouzac (360 points)
Thanks Lukas,

This will solve my problem, i have to use custom approach to display complete email id.
commented Aug 7 by dsouzac (360 points)
I am downloading 2017 R4.1.  does it have fixed this issue?
commented Aug 7 by Lukas Pokorny (85,590 points)
We have not changed this behavior - we don't consider it to be an issue. Of course, It can be argued that a different behavior might be better, but it's mostly a matter of opinion. On the other hand, changing the current behavior would introduce a breaking change with implications for existing projects, which is something we really prefer to avoid if at all possible.
If you need a specific form of the mail address list to display in your UI, the recommended approach is to provide a custom formatting routine. Sorry!
...