Warnning! the applets can run in one of the following ways:
The product comes with the applets and the source code for both cases (including servlet).
Sample applet to send an email (deactivated, please download product):
Sample applet to send this html page (deactivated, please download product):
Programming with RMail
Receiving email 5 lines!
Sample source code to receive email:
pop.connect("pop.mycompany.com","user","pwd"); // Connect
for (int i=1;i<=pop.msgs;i++) { // iterate on number of messages
MailMsg m=pop.retrieveMsg(i); // get message
pop.deleteMsg(i); // delete message// do here whatever you like with the MailMsg object (variable m)
}
pop.disconnect(); // disconnect
Sending an email and attachment 10 lines!
This is a sample source code to send an email:
m=new MailMsg(); // create email
m.from="user1@mycompany.com"; // sender and receiver
m.addRecipient("user2@mycompany.com");
/** for smtp authentication
m.authUser="user";
m.authPwd="password";
m.authMethod=m.AUTH_LOGIN; // other options are AUTH_NONE and AUTH_PLAIN
*/
m.subject="test";
part=new MainMsgPart(); // add text part
part.setData("This is the text",MimeEncoder.QUOTED);
part.addPart(part);
m.addFile(new java.io.File("c:\\mydocument.doc")); // add attachment
m.smtpServer="smtp.mycompany.com";
m.mail(); // send mail
Sending alternative parts (Text and HTML)
This is a sample source code to send an email which contains two versions of the text (plain text and html):
m=new MailMsg(); // create email
m.from="user1@mycompany.com"; // sender and receiver
m.addRecipient("user2@mycompany.com");
m.subject="test";
part=new MainMsgPart(); // create alternative
part.ContentType="Multipart";
part.ContentSubType="Alternative";
textpart=new MainMsgPart(); // add text part to the alternative
textpart.setData("This is the text",MimeEncoder.QUOTED);
part.addPart(textpart);
htmlpart=new MainMsgPart(); // add html part to the alternative
htmlpart.ContentType="Text";
htmlpart.ContentSubType="Html";
htmlpart.setData("<html><body>This is the text</body></html>",MimeEncoder.QUOTED);
part.addPart(htmlpart);
m.addPart(part);
m.smtpServer="smtp.mycompany.com";
m.mail(); // send mail