Created
August 4, 2011 10:05
-
-
Save vijaykiran/1124888 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package controllers; | |
import org.apache.commons.mail.*; | |
import play.*; | |
import play.mvc.*; | |
import play.libs.*; | |
import java.util.*; | |
import models.*; | |
public class Application extends Controller { | |
public static void index() { | |
render(); | |
} | |
public static void sendMail() throws Exception{ | |
EmailAttachment attachment = new EmailAttachment(); | |
attachment.setPath("PATH_TO_FILE"); | |
attachment.setDisposition(EmailAttachment.ATTACHMENT); | |
attachment.setDescription("Picture of John"); | |
attachment.setName("John"); | |
// Create the email message | |
MultiPartEmail email = new MultiPartEmail(); | |
email.setHostName("mail.myserver.com"); | |
email.addTo("jdoe@somewhere.org", "John Doe"); | |
email.setFrom("me@apache.org", "Me"); | |
email.setSubject("The picture"); | |
email.setMsg("Here is the picture you wanted"); | |
// add the attachment | |
email.attach(attachment); | |
Mail.send(email); | |
render(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment