1.//已經用Outlook寫好郵件,就等待發送了,這樣的方式就不用代碼來寫復雜的郵件了
public static void main(String[] args) throws Exception{
Properties props = new PropertIEs();
props.setProperty("mail.smtp.auth", "true");
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", "smtp.sina.com");
Session session = Session.getInstance(props,
new Authenticator()
{
protected PasswordAuthentication getPassWordAuthentication()
{
return new PassWordAuthentication("你的賬號","你的密碼");
}
}
);
session.setDebug(true);
//已經用Outlook寫好郵件,就等待發送了,這樣的方式就不用代碼來寫復雜的郵件了
Message msg = new MimeMessage(session,new FileInputStream("resouce\\demo3.eml"));
Transport.send(msg,InternetAddress.parse("收件人地址"));
}
}