Not able to do till now. Please help.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Prashant_Bhatia
Posted On:   Thursday, June 26, 2003 08:27 AM

Here is my Code and I am still not able to send message as HTML package sparsha1.mail; import javax.mail.*; import javax.mail.internet.*; import java.util.*; public class MailBean { public String send(String p_from, String p_to, String p_subject, String p_message, String p_smtpServer) { String l_result = " "; String l_host = p_smtpServer; Properties l_props = System.getProperties(); l_props.put("mail.smtp.host", l_host); Session l_session = Session.getDefaultInstance(l_props, null); l_session.setDebug(true); try { MimeMessage l_msg = new MimeMessage(l_session); l_msg.setFrom(new Interne   More>>

Here is my Code and I am still not able to send message as HTML


			
package sparsha1.mail;
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
public class MailBean {

public String send(String p_from, String p_to, String p_subject, String p_message, String p_smtpServer)
{
String l_result = " ";
String l_host = p_smtpServer;
Properties l_props = System.getProperties();
l_props.put("mail.smtp.host", l_host);

Session l_session = Session.getDefaultInstance(l_props, null);

l_session.setDebug(true);

try {
MimeMessage l_msg = new MimeMessage(l_session);
l_msg.setFrom(new InternetAddress(p_from));

l_msg.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(p_to, false));


l_msg.setSubject(p_subject);

MimeBodyPart l_mbp = new MimeBodyPart();
l_mbp.setContent(p_message,"text/html");
l_mbp.setText(p_message);
l_mbp.setHeader("Mime-Version", "1.0");
l_mbp.setHeader("Content-Transfer-Encoding", "quoted-printable");
l_mbp.setHeader("X-Mailer", "sendhtml");
l_mbp.setHeader("Content-Type", "text/html");

Multipart l_mp = new MimeMultipart();
l_mp.addBodyPart(l_mbp);

l_msg.setContent(l_mp);

l_msg.setSentDate(new Date());

Transport.send(l_msg);

And the catch goes after this.



The output I get is


			
Dear Sir: < p >Please Issue me a book having: </ p> < br>Book ID:
LB03/GEN/002 < br >Book Name: How < br>Book Dept: All < br >Book Author: Kelly < br >Book
Publisher: Pinks < p>ThankYou very much </ p>Regards < br>Pinkoo Bhatia

What is wrong in the code

Please help me

Regards

Prashant Bhatia
   <<Less
About | Sitemap | Contact