Sign in

Google Wave APIs (Labs)

WaveProtocol.org

Learn about the Google Wave Federation Protocol and get involved

Sample Details

Send Mail from Robot

By: Google Wave APIs Team - Oct 02, 2009

This shows how to send a mail from a robot containing the title of the wave.

package com.google.wave.examples;

import java.util.Properties;

import com.google.wave.api.*;

import javax.mail.MessagingException;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException; 
import javax.mail.internet.InternetAddress; 
import javax.mail.internet.MimeMessage; 

public class MaileyBotServlet extends AbstractRobotServlet {

  @Override
  public void processEvents(RobotMessageBundle bundle) {
    Wavelet wavelet = bundle.getWavelet();
              
    sendEmail(wavelet.getTitle());
  }
  
  public void sendEmail(String title) {
	  Properties props = new Properties();
	    Session session = Session.getDefaultInstance(props, null);
	    
	    try {
	    Message msg = new MimeMessage(session);
	    msg.setFrom(new InternetAddress("pamela.fox@gmail.com"));
	    msg.addRecipient(Message.RecipientType.TO,
	                     new InternetAddress("pamela.fox@gmail.com"));
	    msg.setSubject("the wave " + title + " was updated");
	    msg.setText("it was updated!");
	    Transport.send(msg);
	    } catch (AddressException e) {
            // ...
        } catch (MessagingException e) {
            // ...
        }
  }
}

APIs: Robots

Languages: Java

Tags: mail

*Live demos require Wave Sandbox access to view

Comments (1)

Title

Comments

Your name

 

Please make sure your comments are useful and informative.

?  

Does not work for me =S