package com
import java
import javax
import javax
import javax
public class MailSender {
public final static boolean sendMail(LoadLog sendlog
boolean mailauth
String mailto
String mailmessage
{
MimeMessage mimeMsg;
MimeMultipart mp;
Session session;
String sep[]={
Properties props=new java
int i;
props
try{
session = Session
mimeMsg = new MimeMessage(session);
mp = new MimeMultipart();
if(mailauth)
props
else
props
if (sendlog!=null)
sendlog
}
catch(Exception e)
{
if (sendlog!=null)
sendlog
return false;
}
try
{
mimeMsg
if (sendlog!=null)
sendlog
}
catch(Exception e)
{
if (sendlog!=null)
sendlog
return false;
}
try{
java
if (temp
{
if (sendlog!=null)
sendlog
return false;
}
Address toaddress[] = new Address[temp
for(i=
mimeMsg.setRecipients(Message.RecipientType.TO,toaddress);
if (sendlog!=null)
sendlog.println("Mail To Address: "+mailto);
}
catch(Exception e)
{
if (sendlog!=null)
sendlog.println("Error Mail To,"+e);
return false;
}
if(mailcc != null && mailcc.length()>
{
try{
java
if (temp
{
Address ccaddress[] = new Address[temp
for(i=
ccaddress[i]=InternetAddress
mimeMsg
if (sendlog!=null)
sendlog
}
}
catch(Exception e)
{
if (sendlog!=null)
sendlog
return false;
}
}
try
{
mimeMsg
BodyPart bp = new MimeBodyPart();
bp
mailmessage
mp
}
catch(Exception e)
{
if (sendlog!=null)
sendlog
return false;
}
if(mailattach != null && mailattach
{
try{
java
for(i=
{
MimeBodyPart bp = new MimeBodyPart();
FileDataSource fileds = new FileDataSource(temp
DataHandler dh = new DataHandler(fileds);
bp
bp
bp
mp
}
}
catch(Exception e)
{
if (sendlog!=null)
sendlog
return false;
}
}
try{
mimeMsg
mimeMsg
Session mailSession = Session
Transport transport = mailSession
nnect((String)props
transport
if (sendlog!=null)
sendlog
transport
}
catch(Exception e)
{
if (sendlog!=null)
sendlog
return false ;
}
return true;
}
}
From:http://tw.wingwit.com/Article/program/Java/Javascript/201311/25339.html