import java.util.Properties;
/*import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.PasswordAuthentication;
import javax.mail.Authenticator;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.Multipart;
import javax.mail.MimeMultipart;
import javax.mail.BodyPart;
import javax.mail.MimeBodyPart;*/
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class MultipartExample
{
MultipartExample()
{
try
{
Properties properties=System.getProperties();
properties.setProperty("mail.smtp.host","smtp.gmai l.com");
properties.setProperty("mail.smtp.port","587");
properties.setProperty("mail.smtp.auth","true");
properties.setProperty("mail.smtp.starttls.enable" ,"true");
Session session=Session.getDefaultInstance(properties,new MyAuthentication());
Message message=new MimeMessage(session);
message.setFrom(new InternetAddress("morning.com.hablu@gmail.com"));
message.addRecipient(Message.RecipientType.TO,new InternetAddress("kaliyaodi@gmail.com"));
message.setSubject("Multipart message");
Multipart multipart=new MimeMultipart();
BodyPart bodypart=new MimeBodyPart();
bodypart.setText("Can you get this message....?");
bodypart.setDataHandler(new DataHandler("hiiiii","text/plain"));
//BodyPart bodypart1=new MimeBodyPart();
//bodypart1.setText("My name is");
multipart.addBodyPart(bodypart);
//message.setContent(multipart,"text/html; charset=UTF-8");
//multipart.addBodyPart(bodypart1);
//message.setContent("hekkdjjdj", "text/html; charset=UTF-8");
message.setContent(multipart);
Transport.send(message);
}
catch(Exception e)
{
System.out.println("Exception caught ");
e.printStackTrace();
}
}
public static void main(String args[])
{
new MultipartExample();
}
class MyAuthentication extends Authenticator
{
MyAuthentication()
{
super();
}
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication("morning.com.hablu","rockan dhack");
}
}
}