Plands.com Logo  Business Internet Services 
Main Menu
Home
Planetary CRM
  Benefits
  Features
  Demo
E-Mail Services
  E-mail Hosting
  Newsletters
  Discussion Lists
Web Hosting
Server Co-location
and Administration
Web Applications
Technical Support
Contact Us
DXP Samples
 
DxpHome  ||   Samples  ||   Details  ||   Docs  ||   Trees  ||   xml-xsl  ||   Links
// SendMail.java

The SendMail tag is used to send email to recipients with content produced at runtime. Most of the mail properties are configured at runtime from Parameter values. The content can be dynamically generated or loaded from template files. Runtime values can be inserted into templates. If you want to send separate emails to a number of different recipients the SendBulkMail tag may be a better choice.

The SendMail tag has attributes for mailserver, debug and storeMsg. One or more mailservers can be listed in a comma delmited list. If the first server fails the next on in the list will be tried. If debug is set to true mailservers won't be contacted and no msg is sent. If storeMsg is true the runtime parameters and content that have been added to the msg will be stored under the keys msg.to, msg.from, msg.replyto, msg.cc, msg.bcc, msg.subject, and msg.content.

The rest of the mail properties are specified using Parameter tags. The property names are: to, from, cc, bcc, replyto, subject, content. If a Parameter name matches one of these property names it's value or in some cases, multiple values, will be used to configure the property. Parameters that do not match proptery names will be used find runtime values to insert into the mail msg content.

In this example the msg content is provided by a Cp tag and is hard coded.

<dxp:SendMail mailserver="mail.plands.com" storeMsg="true">
  <dxp:Rp name="to" require="true"/>
  <dxp:Cp name="from" value="mark@plands.com"/>
  <dxp:Cp name="replyto" value="mark@plands.com"/>
  <dxp:Cp name="content">
  This is a short message from Mark so I'm putting it right into the dxp page.
  </dxp:Cp>
</dxp:SendMail>

The Cp content parameter can be replaced with other Parameter tags. In the exmaple below the content comes from a text file that has values inserted at runtime.

<dxp:SendMail mailserver="mail.plands.com" storeMsg="true">
   <dxp:Rp name="to" require="true"/>
   <dxp:Cp name="from" value="mark@plands.com"/>
   <dxp:Cp name="replyto" value="mark@plands.com"/>
   <dxp:Replace name="content" token="*" value="first,last,orderID">
      <dxp:ReadText name="target" filename="mailtemplate.txt"/>
   </dxp:Replace>
</dxp:SendMail> 
The Replace tag inserts values from the parameters name first, last, orderID into a text file and returns the result to be used as the content of the email.

If the debug attribute is set to true the mailserver won't be contacted and no msg is sent. You can use this to store the msg and print display it for testing before sending real mail. To display the msg on the page set storeMsg to true. The runtime content and parameters will stored under the keys msg.to, msg.from, msg.replyto, msg.cc, msg.bcc, msg.subject, and msg.content and can be displayed using Rp tags.


@author Mark Ashworth
@version 0.1, 2001-06-07

Return to Index

Note: We have tried to test all of the code examples but they may contain errors. Any questions, comments, suggestions, or problems should be sent to info@plands.com.