http://wave-samples-gallery.appspot.com/about_app?app_id=35018
By: Google Wave APIs Team - Oct 02, 2009This 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
Комментариев нет:
Отправить комментарий