Google app engine JAVA: how to embed html in mail being sent while using java mail api on google app engine?

this is the working code i'm using to send the mail but if am including html content to the string argument of the setText() method then its being displayed merely as string to the user, no HTML effect.

Message msg = new MimeMessage(session1); msg.setFrom(new InternetAddress("[email protected]", "Team Application")); msg.addRecipient(Message.RecipientType.TO, new InternetAddress(email, "Dear "+name1+".")); msg.setSubject("Registration confirmation mail"); msg.setText("Dear "+name1+",\nThanks for registering with us."); Transport.send(msg);


try using setContent instead of setText
so for your code sample:

Message msg = new MimeMessage(session1);
msg.setFrom(new InternetAddress("[email protected]", "Team Application"));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(email, "Dear "+name1+"."));
msg.setSubject("Registration confirmation mail");
msg.setContent("Dear <i>"+name1+"</i>,<br>Thanks for registering with us.", "text/html");

Personally, for this purpose I use multipart message with text and html version. This is part of my own code:

// Unformatted text version
final MimeBodyPart textPart = new MimeBodyPart();
textPart.setText("plain content");
// HTML version
final MimeBodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent("<b>html content</b>", "text/html");
// Create the Multipart. Add BodyParts to it.
final Multipart mp = new MimeMultipart();
// Set Multipart as the message's content

Checking the MimeMessage documentation, you could you the setText() overloaded signature where you can specify charset and Mime subtype:

msg.setText("Your html body", "utf-8", "html");

You should use MailService.Message and MailService from low-level API. Example:

Message msg = new Message();
msg.setHtmlBody("<h1 style="height:1200px;">THIS IS RUSSIA!!!</h1>");
MailService service = MailServiceFactory.getMailService();
try {
} catch (IOException e) {
// TODO Auto-generated catch block

Category:java Time:2011-07-10 Views:1

Related post

  • Differences between XMPP and Channel API for Google App Engine 2011-06-01

    I am developing an application that doesn't reside on AppEngine and having the functionality of a chat putting in communication web clients (browser + javascript) and mobile clients (ActionScript). I'm thinking of using the XMPP protocol on AppEngine

  • Internal Server Error in Web App: Google Latitude API in Google App Engine using Python 2011-07-13

    I am new to python and Google App Engine. I am currently working on a location based web application, I have used the following sample code I was able to run the program in the localhost, however when I deploy

  • Java API for Google Maps (or similar) 2009-06-15

    Hi i was wondering if there is a Java library that acts as a wrapper for the Google maps API. What i am interested in is displaying a satellite map of a specific region (lon lat) on my desktop application. It doesn't have to be google maps specifical

  • How to implement RESTful API on an App Engine server with webapp ( +Facebook authentication )? 2009-12-28

    so my idea is pretty simple. But I don't know where to start. develop a simple RESTful API on my app engine server using the simple webapp framework. there will be two kinds of clients: 1. Normal pc users access the facebook application, and this wil

  • google java api for google search 2010-01-04

    Does google provide a Java server side api *(NOT java script).*I dont want the ajax api which works at clint side. What i want is that the result returned for a keyword should return me search result in some specific data structure.Like List or set d

  • Skype API or Google Talk/Voice in Java, Android 2011-10-02

    It will use Skype's API or Google Talk/Voice. The app's front screen is very simple. The app is meant to be an intercom through skype, so it will have its own skype account and will call another specific skype account. At the top will be a status bar

  • Tutorial how to create a CXF web service from existing Java code and embed it in Tomcat 2010-04-19

    Do you know a tutorial how to create a CXF soap web service from existing Java code and embed it in Tomcat, and also generate a wsdl file so that any .NET system would be able to generate client code easily? I miss that WSDL creation point in, for ex

  • How to compare two routes using google direction apis or some other apis for iPhone app 2011-12-27

    I want to compare two routes to check if they are same or not in my iPhone app. There is a person X who wants to go to point A to point B and another person wants to go to point A1 to point B1. I can get a route between A to B using this direction AP

  • How to run Ruby/Rails with Resque app in a JRuby/Tomcat deploymet with no JRuby installed and using only Java? 2012-02-03

    I have a JRuby/Rails web application. I use rbenv and JRuby to test locally (using "rails server"), and it works. I also distribute the production version as a WAR file and run in Tomcat, and that machine has no JRuby installation. It works. I now ne

  • JSON library problems using both Facebook API and Google Places API in the same app 2012-04-18

    I'm encountering a problem with the JSON library using both Facebook API and Google Places API in the same app. I've tried them both independently and they work fine. The problem is though that I now have 2 sets of some of the JSON files (when using

  • Calling Twitter API from Google Apps Script 2014-01-07

    I am trying to call Twitter's REST API from Google Apps Script. The code I am using is copied one to one from here: and specifically: function test() { var consumerKey = 'XXXX'; // Co

  • How to embed images in email content using Webservice using java in Netbeans IDE? 2010-07-30

    I want a webservice method() coding in java, that should display images in email as content.The user will upload any kind of images and mail it.Now am able to mail text only, problem is images are not displaying in sent email.Please help me out ASAP,

  • JSON parsing of Google Maps API in Android App 2011-08-29

    I'm trying to use the google maps API to fetch direction times. I'm hoping to create a url, get the JSON response, and then examine that response for travel duration. After I create the JSON object, I have trouble navigating it. To me, this indicates

  • testing mail with appengine development server (java) 2010-06-21

    I'm using javamail to send mails from my appengine application. It works perfectly in the deployment, but I can't figure out how to do this using the development server. Whenever I need to test the sendmail, I'm having to deploy the application which

  • Google Earth API vs Google Earth COM API 2009-12-09

    I want to use Google Earth in a desktop application. My question is which one of these two APIs provided by google do you think has more functionality and/or best support? Thank you very much --------------Solutions------------- Google Earth API is a

  • API for Google Groups 2010-09-21

    I was trying to do some personal project and was wondering if there is an API for google groups. With which we can handle each messages, reply, or do that sort of other operations. I searched and was not lucky enough to get one. if there is no such A

  • Gdata api and Google-api-client-libraries together? 2011-06-16

    Is it possible to use the older GData Apis and the newer google-apis-java-client libraries in the same app? Reason I ask is I am using the new client libraries for accessing spreadsheets in google docs. I would also like to access picasa to upload an

  • SMS API for google application 2011-07-02

    Can you suggest an sms api because I am working on an application that will be able to notify the members via sms. Can anyone suggest a programming language to be used for google applications. --------------Solutions------------- Twilo offers a very

  • which authentication method is better for dealing with Google api and Google accounts on android? 2011-11-01

    follow the link: There are 4 methods there, which are: 1. OAuth 1.0a 2. OAuth 2.0 draft 10 (JavaDoc, specification) 3. Android AccountManager 4. ClientLogin (legacy method that only

  • API for Google Docs Viewer 2012-04-12

    Please refer the below thread from Google Documents List API Group and someone please suggest me a solution. Hi again Jags, Sorry, I missed one thing, you might be able to use the embed link, i.e. that link with rel

Copyright (C), All Rights Reserved.

processed in 0.645 (s). 13 q(s)