I need to create mail application in project,how to create it,could you give me suggestions?

Showing Answers 1 - 1 of 1 Answers

Vamsi

  • Aug 10th, 2006
 

Hi,

The following code will help u to send a mail

 String strHostName="mail.smtp.host";
    Properties props = System.getProperties();
    props.put(strHostName,"localhost");
    Session sessionArgs=Session.getInstance(props, null);
    MimeMessage message =new MimeMessage(sessionArgs);
    message.setFrom(new InternetAddress(strMailFrom));
    message.addRecipient(Message.RecipientType.TO, new InternetAddress(strMailTo));
    message.setSubject(strSubject);
    BodyPart part1 = new MimeBodyPart();
    part1.setContent(bodyContent, "text/html");
    Multipart myMultipart = new MimeMultipart();
    myMultipart.addBodyPart( part1 );
    message.setContent(myMultipart );
    Transport.send(message);

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions