|
Using JavaMail directly The following code-snippet can be used to send multi-mime-parts emails and is also a great example for how to use Java-Classes directly from within Hop. In order for this to work you need the JavaMail-library from Sun. var from = "me@home.com";
var to = "you@home.com";
var title = req.data.title;
var msg = req.data.message;
var file = "c:\\hop\\static\\image.gif";
mail = Packages.javax.mail;
activation = Packages.javax.activation;
var p = java.lang.System.getProperties();
p.put("mail.smtp.host", getProperty("smtp"));
var s = mail.Session.getInstance(p,null);
var m = new mail.internet.MimeMessage(s);
m.setFrom(new mail.internet.InternetAddress(from));
m.addRecipient(mail.Message.RecipientType.TO,
new mail.internet.InternetAddress(to));
m.setSubject(title);
var mText = new mail.internet.MimeBodyPart();
mText.setText(msg);
var mImage = new mail.internet.MimeBodyPart();
var mImageFileDataSource = new activation.FileDataSource(file);
mImage.setDataHandler(
new activation.DataHandler(mImageFileDataSource));
var mp = new mail.internet.MimeMultipart();
mp.addBodyPart(mText);
mp.addBodyPart(mImage);
m.setContent(mp);
mail.Transport.send(m);
sendmail.hacthanks to chris for the snippet!
... comment
|
navigation
Download
Community
Weblog
Mailing Lists
IRC Channel
Documentation
Introductions
Tools
Reference
Project
Roadmap
Bug Reporting
Source
Wiki
Tags
Updates
Related Projects
search
|
||||