Java通过MS Exchange发送邮件(moyosoft解决方案)

目前公司开发的系统要通过客户的Exchange Server发送邮件,在网上找了许多方案,目前使用http://www.moyosoft.com/jbex/的Java Bridge to Exchange解决了该问题,现将代码实现贴出来。


SendMail.java



public class SendMail

{

public static void main(String[] args) throws ExchangeServiceException

{

// To provide hostname and credentials information, use:

Exchange exchange = new Exchange("hostname",                                                             "username", "password", "domain", true);

扫描二维码关注公众号,回复: 1258194 查看本文章


if(exchange == null)

{

return;

}


// Create a new e-mail:

ExchangeMail mail = exchange.createMail();


// Set the recipient, subject and body:

mail.setToRecipient("[email protected]");

mail.setSubject("Test message");

mail.setBody("Hello. There's a message sent from Java.");

// Send the message:

mail.send();

}

}

因为该软件只有一个月的试用期,所以要想长期使用,需要在注册表中修改install_date时间。

猜你喜欢

转载自fansjava.iteye.com/blog/1124474