I am also face the same problem. I can't attach my text to
attachement with mail. Please help me. I didn't get any proper
solution yet.
import java.io.UnsupportedEncodingException;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MailServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
public void doPost(HttpServletRequest req, HttpServletResponse resp)
{
System.out.println(Mail Servlet is called);
Properties properties = new Properties();
Session session = Session.getDefaultInstance(properties, null);
String message = Welcome to www.datastoregwt.com;
String attachement = attachementString for testing ;
try
{
Message msg = new MimeMessage(session);
Multipart mp = new MimeMultipart();
MimeBodyPart bodyPart = new MimeBodyPart();
bodyPart.setContent(attachement, text/plain);
mp.addBodyPart(bodyPart);
MimeBodyPart bodyPart1 = new MimeBodyPart();
bodyPart1.setContent(attachement, text/html);
mp.addBodyPart(bodyPart1);
msg.setFrom(new InternetAddress(rajaganapathiv...@gmail.com,
Rajaganapathi velayutham));
msg.addRecipient(Message.RecipientType.TO, new
InternetAddress(j.gane...@datastoregwt.com, J.Ganesan));
msg.setFrom(new
InternetAddress(rajaganapathiv...@gmail.com,vraja));
msg.addRecipient(Message.RecipientType.TO, new
nternetAddress(vrajaganapathi49...@yahoo.co.in));
msg.setSubject(Invitation from www.datastoregwt.com);
msg.setText(message);
msg.setContent(mp);
Transport.send(msg);
}
catch (AddressException e1)
{
e1.printStackTrace();
}
catch (MessagingException e2)
{
e2.printStackTrace();
}
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
}
}
--
You received this message because you are subscribed to the Google Groups
Google App Engine for Java group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.