@Signature public void __construct() { helper = new MultiPartEmail(); }
@Override public MultiPartEmail get() { return factory.newEmail(new MultiPartEmail()); }
protected MultiPartEmail createMultiPartEmail(String text) { MultiPartEmail email = new MultiPartEmail(); try { email.setMsg(text); return email; } catch (EmailException e) { throw new ActivitiException("Could not create text-only email", e); } }
/** * @param subject 主题 * @param body 内容 * @param attachment 附件 * @param recipients 收件人 */ public static MultiPartEmail getMultiPartEmail(String subject, String body, EmailAttachment attachment, String... recipients) { try { MultiPartEmail multiPartEmail = new MultiPartEmail(); configEmail(subject, multiPartEmail, recipients); multiPartEmail.setMsg(body); // add the attachment if (attachment != null) multiPartEmail.attach(attachment); return multiPartEmail; } catch (EmailException e) { throw new MailException("Unabled to send email", e); } }
/** * Creates a MultiPartEmail. Selects the correct implementation * regarding html (MultiPartEmail) and/or txt content or both. * * Populates the mutlipart email accordingly with the txt / html content. */ @Override public MultiPartEmail createMultiPartEmailWithContent(Mail mail) throws EmailException { MultiPartEmail multiPartEmail; // set if it is a txt or html mail: if (mail.getBodyHtml() == null || mail.getBodyHtml().equals("")) { multiPartEmail = new MultiPartEmail(); multiPartEmail.setMsg(mail.getBodyText()); } else if (mail.getBodyText() == null || mail.getBodyText().equals("")) { multiPartEmail = new HtmlEmail().setHtmlMsg(mail.getBodyHtml()); } else { multiPartEmail = new HtmlEmail().setHtmlMsg(mail.getBodyHtml()).setTextMsg(mail.getBodyText()); } // and return the nicely configured mail: return multiPartEmail; }
mm = new MultiPartEmail(); if(!StringUtils.isEmpty(bodyText)){ mm.setMsg(bodyText);
import org.apache.commons.mail.*; // create the mail 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"); // get your inputstream from your db InputStream is = new BufferedInputStream(MyUtils.getBlob()); DataSource source = new ByteArrayDataSource(is, "application/pdf"); // add the attachment email.attach(source, "somefile.pdf", "Description of some file"); // send the email email.send();
/** * 发送多媒体邮件,可以携带附件信息 * @param urls 附件的URL,key为附件的名称 */ public void sendMultipartEmail(String targetAddress,String title,String content,Map<String,URL> urls) throws Exception { MultiPartEmail email = new MultiPartEmail(); for(Map.Entry<String,URL> entry : urls.entrySet()) { email.attach(entry.getValue(),entry.getKey(),EmailAttachment.ATTACHMENT); } email.setSubject(title); email.addTo(targetAddress); email.setMsg(content); sendEmail(email); }
@JsonIgnore public MultiPartEmail getNewMultipartEmail(final Map<String, Object> params) throws EmailException { MultiPartEmail email = new MultiPartEmail(); generic_params(email, params); return email; }
@Override public MultiPartEmail get() { return factory.newEmail(new MultiPartEmail()); }
import org.apache.commons.mail.*; ... // Create the attachment EmailAttachment attachment = new EmailAttachment(); attachment.setPath("mypictures/john.jpg"); 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); // send the email email.send();
protected MultiPartEmail createMultiPartEmail(String text) { MultiPartEmail email = new MultiPartEmail(); try { email.setMsg(text); return email; } catch (EmailException e) { throw new ActivitiException("Could not create text-only email", e); } }
protected MultiPartEmail createMultiPartEmail(String text) { MultiPartEmail email = new MultiPartEmail(); try { email.setMsg(text); return email; } catch (EmailException e) { throw new ActivitiException("Could not create text-only email", e); } }
protected MultiPartEmail createMultiPartEmail(String text) { MultiPartEmail email = new MultiPartEmail(); try { email.setMsg(text); return email; } catch (EmailException e) { throw new FlowableException("Could not create text-only email", e); } }
/** * Send. * * @param mailInfo * the mail info * @throws EmailException * the email exception * @throws IOException * Signals that an I/O exception has occurred. */ public static void send(final MailInfo mailInfo) throws EmailException, IOException { final MultiPartEmail email = new MultiPartEmail(); email.setCharset("utf-8"); mailInfo.fillEmail(email); email.send(); } }
// Create the attachment EmailAttachment attachment = new EmailAttachment(); attachment.setPath(zipFile); attachment.setDisposition(EmailAttachment.ATTACHMENT); attachment.setDescription("Zip File"); attachment.setName("myfiles.zip"); MultiPartEmail email = new MultiPartEmail(); email.attach(attachment);
MultiPartEmail email = new MultiPartEmail(); email.setHostName("smtp.yourhosthere.com"); email.setSmtpPort(25); // authentication not always needed depending on your environment email.setAuthenticator(new DefaultAuthenticator("username", "password")); email.setTo("to@yourhosthere.com"); email.setFrom("from@yourhosthere.com");
private MultiPartEmail createMail(ErrorReport report) throws EmailException { MultiPartEmail email = new MultiPartEmail(); email.setFrom(Mail.getSender()); email.setSubject(SOFTWARE_NAME + "-" + report.getVersion() + " "+ report.getType() + " [" + report.getIdentifier() + "]: " + report.getSubject()); return email; }
MultiPartEmail email = new MultiPartEmail(); email.setHostName(smtpServer); email.addTo(to); email.setFrom(from); email.setSubject(subject); email.setMsg(msg); email.setSocketTimeout(20000); email.setSocketConnectionTimeout(20000); // SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(); // soapMessage.createAttachmentPart(); // enough for empty body new AttachmentPartImpl(); // enough for empty body // new MimeHeaders(); not enough for empty body email.send();
public static void main(String[] args) throws EmailException { // 创建附件 EmailAttachment attachment = new EmailAttachment(); attachment.setPath("mypictures/john.jpg"); attachment.setDisposition(EmailAttachment.ATTACHMENT); attachment.setDescription("Picture of John"); attachment.setName("John"); // 创建 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"); // 追加附件 email.attach(attachment); // 发送 email.send(); } }