
com.viaoa.html.OAMail Maven / Gradle / Ivy
/*
This software and documentation is the confidential and proprietary
information of ViaOA, Inc ("Confidential Information").
You shall not disclose such Confidential Information and shall use
it only in accordance with the terms of the license agreement you
entered into with ViaOA.
ViaOA MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, OR NON-INFRINGEMENT. ViaOA SHALL NOT BE LIABLE FOR ANY DAMAGES
SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
THIS SOFTWARE OR ITS DERIVATIVES.
Copyright (c) 2001 ViaOA, Inc.
All rights reserved.
*/
package com.viaoa.html;
import java.net.InetAddress;
import java.util.Date;
import java.util.Properties;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.mail.*;
import javax.mail.internet.*;
public class OAMail implements java.io.Serializable {
private static final long serialVersionUID = 1L;
/**
*
* @param host
* @param to
* @param from
* @param subject
* @param text
* @param contentType "text/html", "text/plain", "text/richtext", "text/css", "image/gif"
*/
public void send(String host, String user, String pw, String to, String from, String subject, String text, String contentType) throws Exception {
send(host,user, pw, new String[] {to}, null, from,subject,text, contentType);
}
/*
@param host smtp mail server
@param "mail to" list of addresses to send message to
@param "mail cc" list of addresses to send message to
@param subject mail subject
@parma text mail message
*/
public void send(String host, String user, String pw, String[] to, String[] cc, String from, String subject, String text, String contentType) throws Exception {
String msg = "";
if (contentType == null || contentType.length() == 0) {
// contentType = "text/html; charset=iso-8859-1";
contentType = "text/html; charset=UTF-8";
}
Session session = Session.getInstance(System.getProperties(), null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
for (int i=0; to != null && i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy