hopefully quick one.
essentially using apache commons email v1.3.3 , trying send html format email. have followed user guide email receiving not resolving html in client view in, of support html..
here snippet of code sending it:
htmlemail email = new htmlemail(); email.setsubject(subject); email.setto(getrecipients(recipients)); email.sethtmlmsg(htmlmsg); email.settextmsg(alternativemsg); try { this.mailserver.send(email); } catch (emailexception e) { logger.error("an error occurred sending email. ", e); }
now lets html this:
<html>some text in html <p> blah blah blah </html>
i receiving plain text content above.
could please highlight missing?
thanks,
edit:
having made use of debug feature, can see content-type remains plain/text. resolve issue have instead done this:
email.setcontent(htmlmsg, emailconstants.text_html);
i have been using commons-email library quite time. think, set message using setmsg()
method instead of sethtmlmsg()
. rewrite code below, , should work fine.
htmlemail email = new htmlemail(); email.setsubject(subject); email.setto(getrecipients(recipients)); email.setmsg(htmlmsg); try { this.mailserver.send(email); } catch (emailexception e) { logger.error("an error occurred sending email. ", e); }
there problem faced html email. library adds <pre>
tag our message, , makes styles , alignments bit odd. had override setmsg()
overcome problem.
Comments
Post a Comment