fixed formatting/indentation
This commit is contained in:
parent
f1f9afe13f
commit
6c452b1893
1 changed files with 33 additions and 45 deletions
|
@ -41,19 +41,18 @@ public class ESMail extends ESObject implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
public ESMail (MailExtension mailx) {
|
public ESMail (MailExtension mailx) {
|
||||||
|
super (mailx.esMailPrototype, mailx.evaluator);
|
||||||
super (mailx.esMailPrototype, mailx.evaluator);
|
|
||||||
this.status = OK;
|
this.status = OK;
|
||||||
this.mailx = mailx;
|
this.mailx = mailx;
|
||||||
this.mprops = mailx.mprops;
|
this.mprops = mailx.mprops;
|
||||||
|
|
||||||
// create some properties and get the default Session
|
// create some properties and get the default Session
|
||||||
try {
|
try {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.put ("mail.smtp.host", mprops.getProperty ("smtp", "mail"));
|
props.put ("mail.smtp.host", mprops.getProperty ("smtp", "mail"));
|
||||||
|
|
||||||
Session session = Session.getDefaultInstance(props, null);
|
Session session = Session.getDefaultInstance(props, null);
|
||||||
message = new MimeMessage (session);
|
message = new MimeMessage (session);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
this.evaluator.reval.app.logEvent ("Error in mail constructor: "+t);
|
this.evaluator.reval.app.logEvent ("Error in mail constructor: "+t);
|
||||||
}
|
}
|
||||||
|
@ -76,23 +75,23 @@ public class ESMail extends ESObject implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setText (ESValue val) throws Exception {
|
public void setText (ESValue val) throws Exception {
|
||||||
if (buffer == null)
|
if (buffer == null)
|
||||||
buffer = new StringBuffer ();
|
buffer = new StringBuffer ();
|
||||||
if (val != null)
|
if (val != null)
|
||||||
buffer.append (val.toString ());
|
buffer.append (val.toString ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPart (ESValue val[]) throws Exception {
|
public void addPart (ESValue val[]) throws Exception {
|
||||||
if (val == null || val.length == 0) return;
|
if (val == null || val.length == 0) return;
|
||||||
if (multipart == null) {
|
if (multipart == null) {
|
||||||
multipart = new MimeMultipart ();
|
multipart = new MimeMultipart ();
|
||||||
}
|
}
|
||||||
for (int i=0; i<val.length; i++) {
|
for (int i=0; i<val.length; i++) {
|
||||||
// FIXME: addPart is broken.
|
// FIXME: addPart is broken.
|
||||||
MimeBodyPart part = new MimeBodyPart ();
|
MimeBodyPart part = new MimeBodyPart ();
|
||||||
Object obj = val[i].toJavaObject ();
|
Object obj = val[i].toJavaObject ();
|
||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
|
@ -104,10 +103,10 @@ public class ESMail extends ESObject implements Serializable {
|
||||||
multipart.addBodyPart (part);
|
multipart.addBodyPart (part);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubject (ESValue val) throws Exception {
|
public void setSubject (ESValue val) throws Exception {
|
||||||
if (val == null)
|
if (val == null)
|
||||||
return;
|
return;
|
||||||
message.setSubject (MimeUtility.encodeWord (val.toString (), "iso-8859-1", null));
|
message.setSubject (MimeUtility.encodeWord (val.toString (), "iso-8859-1", null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,8 +114,8 @@ public class ESMail extends ESObject implements Serializable {
|
||||||
String addstring = add.toString ();
|
String addstring = add.toString ();
|
||||||
if (addstring.indexOf ("@") < 0)
|
if (addstring.indexOf ("@") < 0)
|
||||||
throw new AddressException ();
|
throw new AddressException ();
|
||||||
Address replyTo[] = new Address[1];
|
Address replyTo[] = new Address[1];
|
||||||
replyTo[0] = new InternetAddress (addstring);
|
replyTo[0] = new InternetAddress (addstring);
|
||||||
message.setReplyTo (replyTo);
|
message.setReplyTo (replyTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,9 +126,9 @@ public class ESMail extends ESObject implements Serializable {
|
||||||
Address address = null;
|
Address address = null;
|
||||||
if (add.length > 1)
|
if (add.length > 1)
|
||||||
address = new InternetAddress (addstring, MimeUtility.encodeWord (add[1].toString (), "iso-8859-1", null));
|
address = new InternetAddress (addstring, MimeUtility.encodeWord (add[1].toString (), "iso-8859-1", null));
|
||||||
else
|
else
|
||||||
address = new InternetAddress (addstring);
|
address = new InternetAddress (addstring);
|
||||||
message.setFrom (address);
|
message.setFrom (address);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTo (ESValue add[]) throws Exception {
|
public void addTo (ESValue add[]) throws Exception {
|
||||||
|
@ -139,7 +138,7 @@ public class ESMail extends ESObject implements Serializable {
|
||||||
Address address = null;
|
Address address = null;
|
||||||
if (add.length > 1)
|
if (add.length > 1)
|
||||||
address = new InternetAddress (addstring, MimeUtility.encodeWord (add[1].toString (), "iso-8859-1", null));
|
address = new InternetAddress (addstring, MimeUtility.encodeWord (add[1].toString (), "iso-8859-1", null));
|
||||||
else
|
else
|
||||||
address = new InternetAddress (addstring);
|
address = new InternetAddress (addstring);
|
||||||
message.addRecipient (Message.RecipientType.TO, address);
|
message.addRecipient (Message.RecipientType.TO, address);
|
||||||
}
|
}
|
||||||
|
@ -151,7 +150,7 @@ public class ESMail extends ESObject implements Serializable {
|
||||||
Address address = null;
|
Address address = null;
|
||||||
if (add.length > 1)
|
if (add.length > 1)
|
||||||
address = new InternetAddress (addstring, MimeUtility.encodeWord (add[1].toString (), "iso-8859-1", null));
|
address = new InternetAddress (addstring, MimeUtility.encodeWord (add[1].toString (), "iso-8859-1", null));
|
||||||
else
|
else
|
||||||
address = new InternetAddress (addstring);
|
address = new InternetAddress (addstring);
|
||||||
message.addRecipient (Message.RecipientType.CC, address);
|
message.addRecipient (Message.RecipientType.CC, address);
|
||||||
}
|
}
|
||||||
|
@ -163,32 +162,21 @@ public class ESMail extends ESObject implements Serializable {
|
||||||
Address address = null;
|
Address address = null;
|
||||||
if (add.length > 1)
|
if (add.length > 1)
|
||||||
address = new InternetAddress (addstring, MimeUtility.encodeWord (add[1].toString (), "iso-8859-1", null));
|
address = new InternetAddress (addstring, MimeUtility.encodeWord (add[1].toString (), "iso-8859-1", null));
|
||||||
else
|
else
|
||||||
address = new InternetAddress (addstring);
|
address = new InternetAddress (addstring);
|
||||||
message.addRecipient (Message.RecipientType.BCC, address);
|
message.addRecipient (Message.RecipientType.BCC, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send () throws Exception {
|
public void send () throws Exception {
|
||||||
if (buffer != null)
|
if (buffer != null)
|
||||||
message.setText (buffer.toString ());
|
message.setText (buffer.toString ());
|
||||||
else if (multipart != null)
|
else if (multipart != null)
|
||||||
message.setContent (multipart);
|
message.setContent (multipart);
|
||||||
else
|
else
|
||||||
message.setText ("");
|
message.setText ("");
|
||||||
Transport.send (message);
|
Transport.send (message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue