All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nyla.solutions.global.net.email.JDAVMail Maven / Gradle / Ivy

Go to download

Nyla Solutions Global Java API provides support for basic application utilities (application configuration, data encryption, debugger and text processing).

The newest version!
package nyla.solutions.global.net.email;

import javax.mail.*;

import javax.mail.internet.*;

import java.util.*;

/**
 * 
 *  JDAVMail provides a set of functions to send emails via the JDAV protocol
 * 
* * @author Gregory Green * @version 1.0 */ public class JDAVMail implements SendMail { /** * Constructor for JDAVMail initializes internal data settings. */ public JDAVMail() { super(); }// -------------------------------------------- /** * * @see nyla.solutions.global.net.email.SendMail#sendMail(java.lang.String, * java.lang.String, java.lang.String) */ public void sendMail(String aTo, String aFrom, String aSubject, String aMessageBody) throws Exception { try { Properties prop = new Properties(); // Set the default enveloppe sender address prop.setProperty("mail.davmail.from", "[email protected]"); Session ses = Session.getInstance(prop); // Create the transport connection Transport transport = ses.getTransport("davmail_xmit"); transport.connect(null, "green_gregory", "redmoon"); // Prepare the message MimeMessage txMsg = new MimeMessage(ses); txMsg.setSubject("Test subject"); InternetAddress addrFrom = new InternetAddress( aFrom); 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(); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy