Amogh
Amogh

Reputation: 4573

content trasfer encoding for email attachment causing unwated character at line end

I have a HTML file and it's in UTF-16 LE BOM and I am using Java with simple java mail library (which uses jakarta mail internally) to send the mail. When I send the mail by attaching the HTML file, the receiver of the mail see some extra character ਍ഀ at every line ending in the attachment file.

I checked the raw email messages and the attachment is being added having header as Content-Transfer-Encoding: quoted-printable also Content-Type: text/html; charset=UTF-8;.

While sending email I am only detecting MIME type of the file and then give byte[], name of the attachment and detected MIME type to the simple java mail library, I assume that rest work is done either by simeple java mail library or by jakarta mail itself.

questions are:

  1. why library is setting charset as UTF-8 where the file is in UTF-16? Don't they do the detection part?

Also, rather than depending on library if I set header as Content-Transfer-Encoding: base64 then file is being send nicely without any extra character at the end.

  1. So, my program being generic to send any email with any type of attachment how I can detect which is most suitable Content-Transfer-Encoding for any type of attachment?

Upvotes: 0

Views: 35

Answers (0)

Related Questions