Created
February 12, 2012 17:54
-
-
Save fbettag/1809910 to your computer and use it in GitHub Desktop.
mail.scala
This file contains hidden or 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
val props: Properties = System.getProperties() | |
props.put("mail.smtp.from", "[email protected]") | |
val session: Session = Session.getInstance(props, null) | |
val message = new MimeMessage(session) | |
message.setFrom(new InternetAddress("[email protected]", "This is my Name")) | |
message.addRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]"))) | |
message.setSubject("Blubber") | |
val multipart = new MimeMultipart() | |
var messageBodyPart = new MimeBodyPart() | |
messageBodyPart.setText(plainContent + MailHelpers.footer) | |
multipart.addBodyPart(messageBodyPart) | |
messageBodyPart = new MimeBodyPart() | |
val source = new FileDataSource("/some/file.pdf") | |
messageBodyPart.setDataHandler(new DataHandler(source)) | |
messageBodyPart.setFileName("myfile.pdf") | |
multipart.addBodyPart(messageBodyPart) | |
message.setContent(multipart) | |
Transport.send(message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment