0 votes
by (150 points)


Example code:

        var mail = new Rebex.Mail.MailMessage();
        mail.Subject = "FirsName \n LastName";

throws an exception:

An unhandled exception of type 'System.ArgumentException' occurred in
Rebex.Mail.dll Additional information: Invalid character at position

Should internally by component be encoded or removed from subject or is this the correct behaviour and a developer should remove invalid characters from email subject before setting the property.

A similar post is on this address, but I didn't find the answer to the question.


What would be your recommendation for implementation of special characters?

Thank you, Klemen

Applies to: Rebex Secure Mail

1 Answer

0 votes
by (70.4k points)
selected by
Best answer

This is done by design. Our recommendation is to not use non-printable characters (those less than 0x20), except the TAB character.

It is due to email clients, which have problems to display those characters.

Actually, it is possible to encode those characters, but it is strongly discouraged:

mail.Headers.Add("Subject", "=?us-ascii?Q?FirstName =0A LastName?=");

For example Outlook displays only "FirstName ".