connect to Gmail Imap using javamail
来源:互联网 发布:吉林公务员网络学校 编辑:程序博客网 时间:2024/05/21 12:09
import java.util.Properties;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Store;
public class Program {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String host = "imap.gmail.com";
int port = 993;
String user = "xxxxx@gmail.com";
String password = "xxxxx";
String target_folder = "INBOX";
Properties props = System.getProperties();
Session sess = Session.getInstance(props, null);
// sess.setDebug(true);
Store st = sess.getStore("imaps");
st.connect(host, port, user, password);
Folder fol = st.getFolder(target_folder);
if (fol.exists()) {
for (Folder f : fol.list()) {
System.out.println(f.getName());
}
fol.open(Folder.READ_ONLY);
for (Message m : fol.getMessages()) {
System.out.printf("%s - %d/n", m.getSubject(), m.getSize());
}
fol.close(false);
} else {
System.out.printf("%s is not exist.", target_folder);
}
st.close();
}
}
- connect to Gmail Imap using javamail
- Receive Email in Java using JavaMail – GMail IMAP Example
- javamail使用IMAP协议收取gmail邮件
- Couldn't open stream {imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX Cannot connect to serve
- 利用JavaMail通过POP3协议、IMAP协议收取Gmail邮箱
- Accessing an IMAP account using SSL (OpenSSL on Gmail)
- Access GMail with imap using java mail api
- javamail+imap
- Guide to Setup Gmail IMAP in Outlook 2010
- javamail gmail
- Connect to Gmail via SSL commands
- IMAP GMAIL PROCESS
- 输出structure gmail imap
- gmail,imap 接收邮件
- Using VBScript to Send Emails with Gmail
- using DTP to connect to MySQL
- Using WebDav to connect to Plone ZODB
- How to Connect to MySQL Using C#
- 励志篇:重新捡起JAVA
- 学习笔记(一)
- 学习笔记(二)
- Thinking in Java --- Chapter 1 (Notes)
- Windows Live Writer里对CSDN BLOG的配置
- connect to Gmail Imap using javamail
- 实例化函数
- 关于上传组件的配置
- 在weblogic上配置数据源
- 文件分割器
- 8月1日 Linux / Unix
- 得到当前系统信息(公司、用户、日期、语言、数据库信息)
- UNIX 高手的另外 10 个习惯
- 阿里巴巴会员信息采集软件2008版下载