Chapter 3 DynaScript Predefined Objects
The mailPiece
object
has these properties:
mailPiece.body
This property is read/write.
The body text of the mail piece.
Binary data
Binary data must be sent as an attachment.
This example creates an outgoing mail piece. It is assumed that you have set the smtpHost from within Sybase Central:
<!--SQL
mp = new MailPiece();
mp.subject = "Example of the body property";
mp.from = "elmo@sybase.com";
mp.body = "This is the body of the outgoing mail piece.";
mp.AddRecipient( "theGrouch@sybase.com" );
if( !mp.Send() ) {
document.writeln( mp.GetErrorCode() );
document.writeln( mp.GetErrorInfo() );
}
-->
"mailPiece object (incoming)".
mailPiece.from
This property is read/write.
The address from where the mail piece is being sent. This address must be a valid Internet mail user name in canonical form.
This example sends a piece of e-mail to a specific address depending on the input given by the user. The user must also enter their own e-mail address so the recipient knows who to respond to.
Following is the form that requests information from the user:
<HTML>
<BODY>
<H1>Problem tracking</H1>
<p>This Web page is used to filter software problems to the appropriate help personel.
<p>Select the product that you require help for:
<FORM METHOD=POST ACTION='mailsend.ssc'>
<OL>
<LI><INPUT TYPE='radio' Name="product" Value="Product A">Product A
<LI><INPUT TYPE='radio' Name="product" Value="Product B">Product B
<LI><INPUT TYPE='radio' Name="product" Value="Product C">Product C
<LI><INPUT TYPE='radio' Name="product" Value="Product Other">Product Other
</OL>
<P>Enter your mail address:
<INPUT Type="TEXT" Name="from" SIZE=40></P>
<P>Describe your problem:
<INPUT Type="TEXT" Name="body" SIZE="50" ></P>
<INPUT TYPE="SUBMIT">
</FORM>
</BODY>
</HTML>
From a browser, the form would look something like this:
Following is the script (mailsend.ssc) that is called to process the information entered on the form:
<HTML>
<BODY>
<!--SCRIPT mailsend.ssc
product = document.value.product
from = document.value.from
body = document.value.body
mp = new MailPiece();
switch( product ) {
case "Product A":
mp.AddRecipient("prodA@sybase.com");
break;
case "Product B":
mp.AddRecipient("prodB@sybase.com");
break;
case "Product C":
mp.AddRecipient("prodC@sybase.com");
break;
case "Product Other":
mp.AddRecipient("other@sybase.com");
break;
}
mp.subject = "Mail Piece Example";
mp.from = from;
mp.body = body;
if( !mp.Send() ) {
document.writeln( mp.GetErrorCode() );
document.writeln( mp.GetErrorInfo() );
}
-->
<P>Select the back buttom if you wish to send another e-mail</P>
</BODY>
</HTML>
"mailPiece object (incoming)".
mailPiece.sender
This property is read/write.
You can use this property if a mail piece is sent
from a destination other than that of the person who the message
is from. For example, if an assistant wanted to send a message as
requested by their supervisor, mailPiece.sender
would
be the address of the assistant while mailPiece.from
would
be the address of the supervisor.
This example sets the sender property on the mp mailpiece object:
<!--SCRIPT
mp = new MailPiece();
mp.from = "elmo@sybase.com";
mp.sender = "elmojr@sybase.com";
mp.AddRecipient( "oscar@sybase.com" );
mp.subject = "Request for comment";
mp.body = "Your input is needed immediately";
mp.Send();
-->
"mailPiece object (incoming)".
mailPiece.smtpHost
This property is read/write.
Specifies the name of the host to be used as a gateway for sending the mail piece. If this value is empty, the value of smtpHost in the PowerDynamo Configuration folder is used as the gateway. If the smtpHost has not been specified in Sybase Central or the document, the mail piece will not be sent.
For information on setting the smtpHost in Sybase Central see "Changing Dynamo configuration settings" in the PowerDynamo User's Guide.
This example sets the smtpHost as mailsrv.sybase.com:
<!--SCRIPT
mp = new MailPiece();
mp.from = "elmo@sybase.com";
mp.sender = "elmojr@sybase.com";
mp.AddRecipient( "oscar@sybase.com" );
mp.smtpHost="mailsrv.sybase.com";
mp.subject = "Request for comment";
mp.body = "Your input is needed immediately";
mp.Send();
-->
"mailPiece object (incoming)".
mailPiece.body
This property is read/write.
The body text of the mail piece.
Binary data
Binary data must be sent as an attachment.
This example creates a simple outgoing mail piece:
<!--SCRIPT
mp = new MailPiece();
mp.from = "elmo@sybase.com";
mp.AddRecipient( "sam@sybase.com" );
mp.subject = "Request for comment";
mp.body = "Your input is needed immediately";
mp.Send();
-->
"mailPiece object (incoming)".
Copyright © 1999 Sybase, Inc. All rights reserved. |