xml - How to Keep the HTML formatted data as a body of java mail using java mail API? -


i need mail xml validation reports html content mail. how keep below detailed information(derived parent class)as html body using java mail api. //exact requirement: title : car validation report //background color : orange //font color : black 1.total no of errors : 12 2.total no of warnings : 150

car validation successful.

my java code mail:

mimemessage message = new      mimemessage(session);                                                    m_toterr=validatexml.total_err;                 message.setfrom(new internetaddress(from));                    message.addrecipient(message.recipienttype.to, new  internetaddress(to1));                 //message.addrecipient(message.recipienttype.cc, new   internetaddress(to2));                 //message.addrecipient(message.recipienttype.bcc, new  internetaddress(to3));                 //message.addrecipient(message.recipienttype.bcc, new  internetaddress(to4));                 message.setsubject("re : car validation report of :  "+dateformat.format(cal.gettime()));                  message.addheaderline("line");                 mimeheader header1=new mimeheader("content- type","test/html");                 mimebodypart line0 =new mimebodypart();                 mimebodypart line1 = new mimebodypart();                 mimebodypart line2 = new mimebodypart();                 mimebodypart line3 = new mimebodypart();                 mimebodypart line4 = new mimebodypart();                 mimebodypart line5 = new mimebodypart();                 mimebodypart line6 = new mimebodypart();                 mimebodypart line7 = new mimebodypart();                   multipart multipart = new mimemultipart();                        system.out.println("total number of errors @ console  mailer:"+m_toterr);                    //carparser1.logger.info("total number of  errors:"+m_toterr);                   line0.setcontent("<body bgcolor=yellow>","text/html");                   line1.setcontent("<h4 style=color:blue>dear  all,</h4>","text/html");                   line2.setcontent("<br><br><h4 style=color:red>the      below today's car validation status</h4>","text/html");                    line3.setcontent("</p>","text/html");                   line4.setcontent("</body>","text/html");                     //line3.setcontent("<br><h4 style=color:blue>pfa  log file</h4>","text/html");                   //line4.attachfile("d:/logfile.log");                   line4.setcontent("<br><br><h4 style=color:blue>    regards,<br>( e-ops software ) </h5>","text/html");                   line5.setcontent("<br><h4 style=color:red>(auto mail,  please not reply)</h4>","text/html");              //     line7.setcontent("system.out.println(total number of  errors:"+m_toterr);");                    multipart.addbodypart(line0);                   multipart.addbodypart(line1);                   multipart.addbodypart(line2);                   //multipart.addbodypart(line3);                   multipart.addbodypart(line4);                   multipart.addbodypart(line5);                 //  multipart.addbodypart(line6);                  message.setcontent(multipart );                 transport.send(message);                  system.out.println("email sent successfully....");                 carparser1.logger.info("email sent successfully...");                 system.out.println();             }  

--------------code ends

please help.

format data single string html markup, using whatever technique prefer, set string content of single mimebodypart. do not want part each line.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -