When constructing an email message I set both the BodyHtml and BodyText properties of the MailMessage.
The other day I received an exception report with the following stack trace:
Rebex.Mime.MimeException: Body contains characters that are invalid for text.
at Rebex.Mime.MimeEntity.CheckTransferEncoding(MailBodyStream body, ContentType ct, ContentTransferEncoding cte)
at Rebex.Mime.MimeEntity.SetBody(MailBodyStream body, ContentType ct, ContentTransferEncoding cte, String name)
at Rebex.Mime.MimeEntity.SetContentInternal(String text, String mediaType, Encoding charset, ContentTransferEncoding transferEncoding)
at Rebex.Mime.MimeEntity.SetContent(String text, String mediaType)
at Rebex.Mail.AttachmentBase.SetContent(String text, String mediaType)
at Rebex.Mail.MailMessage.set_BodyText(String value)
This was manually fixed by removing the offending character, however, should I be encoding the text before setting this property? If so, to what encoding?
Does BodyText not handle unicode characters?