javamail - Unable to send richtext content type mail to outlook using java mail -
i sending mail outlook using java mail api. able send plain text , html content mail when set content type text/richtext receive mail in plain text only.
can body suggest how send richtext mail? here tried:
// parent or main part if multipart mainmultipart = new mimemultipart("related"); // hold text , html , tells client there 2 versions of message (html , text). presumably text // being alternative html multipart htmlandtextmultipart = new mimemultipart("alternative"); // set html mimebodypart htmlbodypart = new mimebodypart(); htmlbodypart.setcontent("hi", "text/richtext"); htmlandtextmultipart.addbodypart(htmlbodypart); mimebodypart htmlandtextbodypart = new mimebodypart(); htmlandtextbodypart.setcontent(htmlandtextmultipart); mainmultipart.addbodypart(htmlandtextbodypart); message.setcontent(mainmultipart);
first - try adding richtext content, not plaintext:
{\rtf1\ansi\deff0 {\fonttbl {\f0 courier;}} {\colortbl;\red0\green0\blue0;\red255\green0\blue0;} line default color\line \cf2 \tab line red , has tab before it\line \cf1 \page line default color , first line on page 2 }
in code might
htmlbodypart.setcontent("{\\rtf1\\ansi\\deff0 {\\fonttbl {\\f0 courier;}}\r\n" + "{\\colortbl;\\red0\\green0\\blue0;\\red255\\green0\\blue0;}\r\n" + "this line default color\\line\r\n" + "\\cf2\r\n" + "\\tab line red , has tab before it\\line\r\n" + "\\cf1\r\n" + "\\page line default color , first line on page 2\r\n" + "}", "text/richtext");
then might want think providing alternative text - have 2 different versions.
last helps lot use email client allows @ mime source of received message - mozilla thunderbird does.
Comments
Post a Comment