1. Introduction
JDAVMail is a JavaMail service provider. It implements a protocol, inspired from WebDAV, allowing you to access Hotmail via a JavaMail-compliant client.
2. Installation
- The JDAVMail 'jar' file, as well as other required jars (commons-httpclient.jar, jdom.jar, commons-logging.jar, ...) should be reachable by your VM's classloader (classpath, ...)
- Some required jars are not included in the distribution: mail.jar, activation.jar and a xml 'sax' parser like Xerces-J.
3. Example
If you write your own client, here follows a very naive sample program:
package com.posisoft.jdavmail;
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
/**
*/
public class TestReceive {
public static void main(String[] args) {
try {
Properties prop = new Properties();
Session ses = Session.getInstance(prop);
Store store = new JDAVMailStore(ses, null);
store.connect(null, "your_hotmail_account", "your_hotmail_password");
if (store.isConnected()) {
Folder inbox = store.getFolder("INBOX");
if (inbox.exists()) {
inbox.open(Folder.READ_ONLY);
int nCount = inbox.getMessageCount();
System.out.println("Inbox contains " + nCount + " messages");
// Get the last message in the Inbox
MimeMessage msg = (MimeMessage)inbox.getMessage(nCount);
System.out.println("Subject : " + msg.getSubject());
System.out.println("From : " + msg.getFrom()[0].toString());
System.out.println("Content type : " + msg.getContentType());
System.out.println(msg.getContent());
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
It is now possible to send messages as well:
public class TestSend {
public static void main(String[] args) {
try {
Properties prop = new Properties();
// Set the default enveloppe sender address
prop.setProperty("mail.davmail.from", "your_hotmail_account@hotmail.com");
Session ses = Session.getInstance(prop);
// Create the transport connection
Transport transport = ses.getTransport("davmail_xmit");
transport.connect(null, "your_hotmail_account", "your_hotmail_password");
// Prepare the message
MimeMessage txMsg = new MimeMessage(ses);
txMsg.setSubject("Test subject");
InternetAddress addrFrom = new InternetAddress("your_hotmail_account@hotmail.com");
txMsg.setFrom(addrFrom);
InternetAddress addrTo = new InternetAddress("your_recipient's_address", "your_recipient's_name");
txMsg.addRecipient(Message.RecipientType.TO, addrTo);
txMsg.setText("Hello world !");
txMsg.setSentDate(new Date());
// Send the message
transport.sendMessage(txMsg, txMsg.getAllRecipients());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
4. Clients ?
I've tested the library rather successfully with ICEMail. Basic functions are working correctly. HTML mails are likely to throw a 'ChangedCharsetException' (If you understand why, please email me!). You will have to use the following parameters:
- Store protocol: davmail
- Server hostname: services.msn.com
- Server account: your Hotmail account
- Server password: your Hotmail password
- File Path: /svcs/hotmail/httpmail.asp
If you know other clients, please let me know.
5. Contact
The JDAVMail project page is located at: http://jdavmail.sourceforge.net
Luc Claes (luc@posisoft.com)
没有合适的资源?快使用搜索试试~ 我知道了~
java邮件发送hotmail JDAVMail.0.9.006.zip
共29个文件
java:20个
jar:4个
txt:3个
需积分: 32 13 下载量 103 浏览量
2016-01-26
17:16:24
上传
评论
收藏 455KB ZIP 举报
温馨提示
java邮件发送hotmail JDAVMail.0.9.006.zip
资源推荐
资源详情
资源评论
收起资源包目录
JDAVMail.0.9.006.zip (29个子文件)
releases.txt 2KB
license.txt 26KB
build.xml 4KB
src
com
posisoft
jdavmail
JDAVMailMessage.java 11KB
QueryFoldersMethod.java 4KB
JDAVMethodBase.java 3KB
FlagMailReadMethod.java 3KB
JDAVMailStore.java 4KB
PostMessageMethod.java 3KB
GetFolderInfoMethod.java 3KB
CopyMessageMethod.java 2KB
JDAVMailFolder.java 9KB
package.html 2KB
Util.java 3KB
JDAVMailTransport.java 3KB
FolderProxy.java 14KB
GetMessageMethod.java 3KB
DeleteFolderMethod.java 2KB
CreateFolderMethod.java 2KB
JDAVMailService.java 15KB
GetFolderContentMethod.java 3KB
MoveMessagesMethod.java 4KB
JDAVMail.java 3KB
MoveMethod.java 3KB
lib
jdom.jar 144KB
commons-httpclient-2.0-final.jar 217KB
commons-logging.jar 31KB
readme.txt 3KB
JDAVMail.0.9.006.jar 37KB
共 29 条
- 1
资源评论
HL299782458
- 粉丝: 0
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功