0 votes
by (120 points)

To whom it may concern,

So we are using Rebex (1.0.3854) in our email solution. Today we found an attachment which happens to include a single occurrence of LF (not accompanied by CR) and thus fails your Attachment constructor.

We tried base64 encoding, which Gmail adopts. In spite of that, Rebex seems to validate text before apply encoding. So we ended up with the same error information. Potentially we could also clean up user input, i.e. changing every LF into CRLF. But ideally we'd want to refrain from modifying user input.

Could you shed some light on this?

Thanks, Bangxin

Applies to: Rebex Secure Mail

1 Answer

0 votes
by (58.9k points)

You can disable the invalid characters check by using the MimeOptions.AllowAnyTextCharacters option. You would be able to work with attachments which contain e.g. LF character then (as in this code snippet):

byte[] content = new byte[] { 72, 69, 76, 76, 79, 10 };
var att = new Attachment();

att.Options |= Rebex.Mime.MimeOptions.AllowAnyTextCharacters;
att.SetContent(new MemoryStream(content), "attachment.txt", "text/plain");