OpenWGA 7.9 - TMLScript reference

Mail
Method :

prepareMessage()

On object Mail
Usage Creates a Java object javax.mail.internet.MimeMessage from the configured settings
Description Use this method if you want to use the Mail object to compose an E-Mail but need to do some custom operations on it which you are unable to do on the Mail object itself. You can first add all neccessary data to the Mail object and then, instead of sending it, call this method to get the native Java mail object on which you can perform a variety off additional operations. See the Java-Mail API Reference for details.

After you modified the MimeMessage object you can again use the Mail object to send it using them method mail.send with is as parameter.
Return value Java object of type javax.mail.internet.MimeMessage representing the preconfigured mail
Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
    portletevent
Examples This example first creates a mail via the Mail object and fills it with basic data. Then it uses the prepareMessage() object to create the corresponding Java-Mail API object. On this object it is possible to set the "Content-ID", a property that can be used to provide an unique identifier for the content of this mail. Finally the message object is sent.

var mail = createMail();
mail.setTo("address@host.de");
mail.subject = "The subject";
mail.body = "This is the body of the mail";
mail.from = "me@home.de"
var message = mail.prepareMessage();
message.setContentID(myContentID);
mail.send(message);