I don't know what mistake i done on my code segment to  send e-mail
using Google App Engine. I refered the documentation of Google App
Engine from http://code.google.com/appengine/docs/python/mail/sendingmail.html.

I attach my code segment of client and server.

Clientside code.

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;

public class MainEntry implements EntryPoint {
        RequestBuilder rb = null;

        @Override
        public void onModuleLoad() {
                // Window.Location.replace("/hello");
                rb = new RequestBuilder(RequestBuilder.POST, "mailserver");
                rb.setCallback(new RequestCallback() {

                        @Override
                        public void onResponseReceived(Request request, 
Response response)
{
                                // TODO Auto-generated method stub
                                Window.alert("Mail send");
                        }

                        @Override
                        public void onError(Request request, Throwable 
exception) {
                                // TODO Auto-generated method stub

                        }
                });
                Button button = new Button("Mail service");
                button.addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {
                                // TODO Auto-generated method stub

                                try {
                                        rb.send();
                                } catch (RequestException e) {

                                }
                        }
                });

                RootPanel.get().add(button);
        }

Serverside code.

import java.io.UnsupportedEncodingException;
import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

public class MailServlet extends HttpServlet {

        /**
         *
         */
        private static final long serialVersionUID = 1L;

        public void init(ServletConfig config) throws ServletException {
                super.init(config);
                System.out.println("Mail Servlet is called");
                Properties properties = new Properties();
                Session session = Session.getDefaultInstance(properties, null);
                String message = "Welcome to WWW.DataStoreGwt.com";
                try
                {
                        Message msg = new MimeMessage(session);
                        msg.setFrom(new InternetAddress("gan.tan...@gmail.com",
"Rajaganapathi velayutham"));
                        msg.addRecipient(Message.RecipientType.TO, new
InternetAddress("j.gane...@datastoregwt.com", "J.Ganesan"));
                        msg.setSubject("Invitation from www.tanya.com");
                        msg.setText(message);
                        Transport.send(msg);

                }
                catch (AddressException e1)
                {

                }
                catch (MessagingException e2)
                {

                }
                catch (UnsupportedEncodingException e)
                {
                        e.printStackTrace();
                }
        }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to