Unable to send emails with attachment using Groovy -
i not know why unable import class multipartemail
. seems code not work unless multipartemail
class imported.
// importing groovy classes import org.apache.commons.mail.*; // create attachment emailattachment attachment = new emailattachment(); attachment.setpath("libraries/pictures"); attachment.setdisposition(emailattachment.attachment); attachment.setdescription("company logo.jpg"); attachment.setname("mycompany"); // create email message multipartemail email = new multipartemail(); email.sethostname("255.255.255.0"); email.setport("25") email.addto("addemailhere", "name"); email.setfrom("from@anywhere.net", "sam"); email.setsubject("email groovy"); email.setmsg("test email"); // add attachment email.attach("company logo.jpg"); // send email email.send();
Comments
Post a Comment