Java Code Examples for org.apache.commons.mail.EmailAttachment#setDisposition()

The following examples show how to use org.apache.commons.mail.EmailAttachment#setDisposition() . 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 vote down vote up
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 vote down vote up
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 vote down vote up
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 vote down vote up
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 vote down vote up
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;
}