![](/img/trans.png)
[英]Digitally sign MS Office (Word, Excel, etc..) and PDF files on the server
[英]Attaching MS Word, Excel and pdf files in Email
以下是我發送電子郵件的代碼,效果很好。
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package myWorkingFiles;
import org.apache.commons.mail.*;
/*
*
* @author xyz
*/
public class GmailEmailWorking {
public static void main(String[] args) {
String myEmailId = "myEmailId@gmail.com";
String myPassword = "myPassword";
String senderId = "senderId@yahoo.co.in";
try {
Email email = new SimpleEmail();
email.setSmtpPort(587);
email.setAuthenticator(new DefaultAuthenticator(myEmailId, myPassword));
email.setDebug(true);
email.setHostName("smtp.gmail.com");
email.setFrom(myEmailId);
email.setSubject("Hi");
email.setMsg("This is a test mail ... :-)");
email.addTo(senderId);
email.setTLS(true);
email.send();
System.out.println("Mail sent!");
} catch (Exception e) {
System.out.println("Exception :: " + e);
}
}
}
現在,我想發送帶有附件的電子郵件,與上面顯示的普通電子郵件相反。
請讓我知道我需要做哪些更改? 我相信這很簡單,但可惜Google先生也沒有幫助我。
我發現了一些鏈接,但它們沒有用。
快速搜索使我着迷於此。.http ://commons.apache.org/email/userguide.html
您是否在嘗試尋找不同的東西?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.