Java Code Examples for org.apache.commons.mail.EmailAttachment#setPath()
The following examples show how to use
org.apache.commons.mail.EmailAttachment#setPath() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmailManager.java From Notebook with Apache License 2.0 | 6 votes |
private void attachFile(ImageHtmlEmail email, EmailFrom emailFrom) { if(!emailFrom.isAttached()){ return; } // �������� EmailAttachment attachment = new EmailAttachment(); // ����·�� attachment.setPath(emailFrom.getAttachmentPath()); // ����·�� // attachment.setURL(new URL("http://www.baidu.com/xx.zip")); attachment.setDisposition(EmailAttachment.ATTACHMENT); // �������� // attachment.setDescription("����Ͷ�帽��"); // �������� attachment.setName(emailFrom.getAttachmentName()); // ������Ӷ������ // email.attach(attachment1); // email.attach(attachment2); try { email.attach(attachment); } catch (EmailException e) { e.printStackTrace(); } }
Example 2
Source File: SendEmail.java From sAINT with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void sendEmailAttachment(String email_to, String assunto, String msg, String file_logs) { File fileLogs = new File(file_logs); EmailAttachment attachmentLogs = new EmailAttachment(); attachmentLogs.setPath(fileLogs.getPath()); attachmentLogs.setDisposition(EmailAttachment.ATTACHMENT); attachmentLogs.setDescription("Logs"); attachmentLogs.setName(fileLogs.getName()); try { MultiPartEmail email = new MultiPartEmail(); email.setDebug(debug); email.setHostName(smtp); email.addTo(email_to); email.setFrom(email_from); email.setAuthentication(email_from, email_password); email.setSubject(assunto); email.setMsg(msg); email.setSSL(true); email.attach(attachmentLogs); email.send(); } catch (EmailException e) { System.out.println(e.getMessage()); } }
Example 3
Source File: SendEmail.java From SpyGen with Apache License 2.0 | 5 votes |
public void attach(String file, String description) { File f = new File(file); EmailAttachment attachment = new EmailAttachment(); attachment.setPath(f.getPath()); attachment.setDisposition(EmailAttachment.ATTACHMENT); attachment.setDescription(description); attachment.setName(f.getName()); try { this.email.attach(attachment); } catch (EmailException se) { se.printStackTrace(); } }
Example 4
Source File: SendEmail.java From sAINT with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void sendEmailAttachment(String email_to, String assunto, String msg, String file, String file_logs) { File fileScreenshot = new File(file); EmailAttachment attachment = new EmailAttachment(); attachment.setPath(fileScreenshot.getPath()); attachment.setDisposition(EmailAttachment.ATTACHMENT); attachment.setDescription("Attachment"); attachment.setName(fileScreenshot.getName()); File fileLogs = new File(file_logs); EmailAttachment attachmentLogs = new EmailAttachment(); attachmentLogs.setPath(fileLogs.getPath()); attachmentLogs.setDisposition(EmailAttachment.ATTACHMENT); attachmentLogs.setDescription("Logs"); attachmentLogs.setName(fileLogs.getName()); try { MultiPartEmail email = new MultiPartEmail(); email.setDebug(debug); email.setHostName(smtp); email.addTo(email_to); email.setFrom(email_from); email.setAuthentication(email_from, email_password); email.setSubject(assunto); email.setMsg(msg); email.setSSL(true); email.attach(attachment); email.attach(attachmentLogs); email.send(); } catch (EmailException e) { System.out.println(e.getMessage()); } }
Example 5
Source File: Mail.java From JARVIS with MIT License | 5 votes |
public void setAttachment(String path,String Description,String name) { EmailAttachment attachment = new EmailAttachment();//�������� attachment.setPath(path);//���ظ���������·�� attachment.setDisposition(EmailAttachment.ATTACHMENT); attachment.setDescription(Description);//�������� attachment.setName(name);//�������� this.attachment = attachment; }
Example 6
Source File: MailSender.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * 设置要发送的附件 * @param attachment * 附件数组 * @throws MessagingException * @throws UnsupportedEncodingException * @throws EmailException ; */ public void setMixMail(File[] attachment) throws MessagingException, UnsupportedEncodingException, EmailException { if (attachment != null) { for (File file : attachment) { EmailAttachment attach = new EmailAttachment(); attach.setPath(file.getAbsolutePath()); attach.setName(MimeUtility.encodeText(file.getName())); email.attach(attach); } } }
Example 7
Source File: MailSender.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * 设置要发送的附件,并对附件重命名 * @param attachment * 附件的集合,key 为附件的名称,value为附件 * @throws MessagingException * @throws UnsupportedEncodingException * @throws EmailException ; */ public void setMixMailRename(Map<String, File> attachment) throws MessagingException, UnsupportedEncodingException, EmailException { if (attachment != null) { for (String fileName : attachment.keySet()) { EmailAttachment attach = new EmailAttachment(); attach.setPath(attachment.get(fileName).getAbsolutePath()); attach.setName(MimeUtility.encodeText(fileName)); email.attach(attach); } } }
Example 8
Source File: MailSender.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * 设置要发送的附件 * @param attachment * 附件数组 * @throws MessagingException * @throws UnsupportedEncodingException * @throws EmailException ; */ public void setMixMail(File[] attachment) throws MessagingException, UnsupportedEncodingException, EmailException { if (attachment != null) { for (File file : attachment) { EmailAttachment attach = new EmailAttachment(); attach.setPath(file.getAbsolutePath()); attach.setName(MimeUtility.encodeText(file.getName())); email.attach(attach); } } }
Example 9
Source File: MailSender.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * 设置要发送的附件,并对附件重命名 * @param attachment * 附件的集合,key 为附件的名称,value为附件 * @throws MessagingException * @throws UnsupportedEncodingException * @throws EmailException ; */ public void setMixMailRename(Map<String, File> attachment) throws MessagingException, UnsupportedEncodingException, EmailException { if (attachment != null) { for (String fileName : attachment.keySet()) { EmailAttachment attach = new EmailAttachment(); attach.setPath(attachment.get(fileName).getAbsolutePath()); attach.setName(MimeUtility.encodeText(fileName)); email.attach(attach); } } }