C# >NET - ContentId gets escaped if it contains a comma and @

0 votes
asked Aug 27, 2019 by Greg573 (150 points)


I've noticed that when I create a new Attachment and try to set its ContentId property to a string that contains a comma "," and "@", the created value is getting escaped in an unexpected way:

attachment.ContentId = "a,b@mymail.com";

When I retrieve the value of it again, it's modified to:


How can I prevent the ContentId from being modified?

Thanks in advance and regards,

Applies to: Rebex Secure Mail

1 Answer

0 votes
answered Aug 27, 2019 by Lukas Matyska (57,170 points)
selected Aug 27, 2019 by Greg573
Best answer

The attachment.ContentId is parsed as mail address by default. Since comma ',' is standard separator for mail addresses the value "a,b@mymail.com" is quoted to "a,b"@mymail.com automatically.

To disable this conversion, you have to put whole value to quotes e.g. like this:

attachment.ContentId = '"' + "a,b@mymail.com" + '"';