Receive POP3 Emails using Java

Take a look at this example on how to read pop3 emails. But there are 3 parameters you need to prepare: your pop3 server, username and passowrd for that server. Pretty straight forward, not much to explain. All that is missing is the readContent() function which prints the message.getContent(). First you need to understand that an Email message content can be just a regular String or an input stream, but in most cases it is a Multipart object which can be composed of different parts of different types. It can also actually contain inner multiparts. Take a look at readContent() You will also need the mail.jar that can be found here. download source

Sending Email through GMail

In my last 2 posts I have shown you how to send SMTP email using Java. But I still haven’t shown how to send an Email through a secured SMTP server. To do so I’ll show you how to use GMail secured SMTP server to send Emails. Take a look at this class: The basic is the same, like sending a simple SMTP message. What’s different here is the creation of the Session object in the function getGmailSession(). The Session object is created with much more properties and with the Authenticator which holds the authentication properties. You will also need the mail.jar that can be found here. download source

2 usefull freeware

I would like to tell you about 2 freeware tools that I use daily. BareGrep Bare Grep is a file and inner file searching tool. It has all the basic search options like reg-ex and wild card search. BareTail. Bare Tail is a log file monitoring tool. It can highlight log rows by predefined strings. The reason I love these 2 tools is: A. They are freeware(yeah I know there are paid versions but the freeware versions are not bad at all). B. They are very straight forward. C. Most important – they are extremely light-wight. Very recommended. Download from products web site.

Send a multipart SMTP email message with java

In my last post I have shown how to send a simple SMTP email message. This is good only for simple text messages, no HTML or attachments. In this post I’ll show how to send multipart email messages, which can include HTML code, attachments and inner images. First, take a look at this example from the last post. Now lets enhance that to add other features. HTML Email We still need to create a MimeMessage object, but we also need to create a Multipart object. The Multipart object contains parts of the message which can be of different types. The inner types are objects from type BodyPart , here we use MimeBodyPart with text/html format. Notice also that instead of using “message.setText();” we use “message.setContent(Multipart);”. Email with attachments Sending an Email with a attachment is actually not that different. Instead of using “MimeBodyPart.setContent()” we use “MimeBodyPart.setDataHandler()” and “MimeBodyPart.setFileName()”. Email with inline images Sending an Email with inner images is kind of combination between the two, because you need to add the image as an attachment and you also need to reference it inside an HTML body part. Notice that adding an inline image means you have to add the image Continue reading Send a multipart SMTP email message with java