Hi,

Did you try "msg.setText(...);" to set message plain-text ?

--L

On Apr 11, 3:57 am, MobiUcare <mobiuc...@gmail.com> wrote:
> when sending email, sometimes such error occurs
>
> does it mean that "contents" is empty?
>
> --------- error -------------
> com.skyppond.mdm.controller.rpc.DeviceRegisterController register:
> Send failure (javax.mail.MessagingException: Illegal Arguments
> (java.lang.IllegalArgumentException: Bad Request: Missing body))
>
> ------- code ---------
> public void sendRegistrationEmail(UserVO user, DeviceVO device)
>                         throws Exception {
>
>                 Properties props = new Properties();
>                 Session session = Session.getDefaultInstance(props, null);
>
>                 Message msg = new MimeMessage(session);
>
>                 String localeStr = user.getLocale();
>                 if (localeStr == null) {
>                         localeStr = "en_US";
>                 }
>
>                 Locale locale = new Locale(localeStr.substring(0, 2),
>                                 localeStr.substring(3));
>
>                 msg.setFrom(new InternetAddress(AllConfig.SUPPORT_EMAIL,
>                                 "MobiUCare Support"));
>
>                 msg.addRecipient(Message.RecipientType.TO,
>                                 new InternetAddress(user.getEmail()));
>
>                 msg.addRecipient(Message.RecipientType.BCC, new 
> InternetAddress(
>                                 AllConfig.SUPPORT_EMAIL));
>
>                 String encodingOptions = "text/html; charset=UTF-8";
>                 msg.setHeader("Content-Type", encodingOptions);
>
>                 msg.setSubject(MimeUtility.encodeText(
>                                 this.getLocalizedMessage(locale, 
> "email.registration.title"),
>                                 "UTF-8", "Q"));
>
>                 String contents = readContents(EMAIL_URL_REGISTRATION + 
> "?language="
>                                 + locale.getLanguage());
>
>                 if(contents!=null){
>                 logger.info("Email contents size : "+contents.length());
>                 }
>
>                 Multipart mp = new MimeMultipart();
>                 MimeBodyPart htmlPart = new MimeBodyPart();
>                 htmlPart.setContent(contents, "text/html; charset=UTF-8");
>
>                 mp.addBodyPart(htmlPart);
>
>                 msg.setContent(mp);
>
>                 Transport.send(msg);
>
>                 logger.info("EMAIL SENT : " + user.getEmail());
>
>         }

-- 
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.

Reply via email to