This program is used to accept messages with HTML information
void Jbutton7_actionperformed (ActionEvent e) {
Try
{
Properties props = System.getproperties ();
Authenticator auth = new Email_autherticator ();
Props.put ("Mail.smtp.host", host);
Props.put ("Mail.smtp.auth", "true");
Session session = Session.getdefaultinstance (Props,auth);
Store store = Session.getstore ("POP3");
Store.connect (Host,username,password);
After connecting to the store,you can get a Folder,which must is opened before you can read messages from it:
Folder folder = Store.getfolder ("INBOX");
Folder.open (Folder.read_write);
Message message[] = Folder.getmessages ();
Get information about a message and manipulate each part of it
Part messagepart = Message[i];
Object out_content = Messagepart.getcontent ();
if (out_content instanceof Multipart)
{
MessagePart = ((Multipart) out_content). Getbodypart (0);
System.out.println ("[Multipart message]");
}
String Out_content_type = Messagepart.getcontenttype ();
System.out.println ("CONTENT:" +out_content_type);
Jeditorpane1.settext ("");//show it on Jeditorpanel
Jeditorpane1.setcontenttype ("text/html");
Jeditorpane1.settext ((String) out_content);
Jeditorpane1.seteditable (FALSE);
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.