设为首页 加入收藏

TOP

Android中使用JavaMail发送Email带群发加附件(二)
2014-11-24 07:40:23 来源: 作者: 【 】 浏览:4
Tags:Android 使用 JavaMail 发送 Email 群发 附件
Text(_body);
_multipart.addBodyPart(messageBodyPart);
// Put parts in message
msg.setContent(_multipart);
// send email
Transport.send(msg);


return true;
} else {
return false;
}
}


public void addAttachment(String filename) throws Exception {
BodyPart messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(filename);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(filename);


_multipart.addBodyPart(messageBodyPart);
}


@Override
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(_user, _pass);
}


private Properties _setProperties() {
Properties props = new Properties();


props.put("mail.smtp.host", _host);


if(_debuggable) {
props.put("mail.debug", "true");
}


if(_auth) {
props.put("mail.smtp.auth", "true");
}


props.put("mail.smtp.port", _port);
props.put("mail.smtp.socketFactory.port", _sport);
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");


return props;
}


// the getters and setters
public String getBody() {
return _body;
}


public void setBody(String _body) {
this._body = _body;
}


// more of the getters and setters …..
}


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇剖析cocos2d-x之Action实现 下一篇Android中用intent发送邮件

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Asus Armoury Crate (2025-12-26 02:52:33)
·WindowsFX (LinuxFX) (2025-12-26 02:52:30)
·[ Linux运维学习 ] (2025-12-26 02:52:27)
·HTTPS 详解一:附带 (2025-12-26 02:20:37)
·TCP/IP协议到底在讲 (2025-12-26 02:20:34)