Chapter 3 DynaScript Predefined Objects
The incoming mail piece object has these methods:
mailPiece.Delete( )
Marks a mail piece for deletion. The mail piece is not actually deleted until the POP3 server is disconnected.
Boolean.
This example marks a mail piece for deletion:
<!--SCRIPT
mlist = new MailList ("mail.sybase.com", "elmo", "dynamo", "elmo@mail.sybase.com");
for (i in mlist) {
inPiece = mlist[i];
inPiece.Retrieve();
document.WriteLn(inPiece.body);
inPiece.Delete();
}
-->
mlist.Disconnect();
"mailPiece object (outgoing)".
mailPiece.Forward( userName [, includeAttachments] )
Prepares an outgoing mail piece object to be forwarded with all the appropriate properties and recipients specified from the incoming mail piece. The forwarded mail piece may be edited and then sent with the outgoing mail piece send method. The parameters are:
Setting the smtpHost
You must either set the smtpHost
property or specify a default for it in Sybase Central before you
can forward a message using this method.
Outgoing mail piece object.
This example forwards a piece of mail:
<!--SCRIPT
mlist = new MailList ("mail.sybase.com", "elmo", "dynamo", "elmo@mail.sybase.com");
mlistitem = mlist[0];
mlistitem.Retrieve();
forwardmp = mlistitem.Forward("sam@sybase.com")
document.writeln(forwardmp.body);
forwardmp.body = ( "Please review this mail piece " + forwardmp.body );
forwardmp.Send();
-->
"mailPiece object (outgoing)".
mailPiece.GetErrorCode( )
Returns a code representing the most recently generated error. The error generated will either be a three-digit POP3 reply code or a three-digit code in the 900 range generated by Dynamo.
Integer.
This example checks that the send method was completed successfully:
<!--SCRIPT
mlist = new MailList ("mail.sybase.com", "elmo", "dynamo", "elmo@mail.sybase.com");
mlistitem = mlist[0];
mlistitem.Retrieve();
forward = mlistitem.Forward("jim@sybase.com");
if( !forward.Send() ) {
document.writeln( forward.GetErrorCode() );
document.writeln( forward.GetErrorInfo() );
}
-->
"mailPiece object (outgoing)".
mailPiece.GetErrorInfo( )
Returns a string containing an error message. The error generated is either a reply from the POP3 server or from PowerDynamo.
String.
This example verifies that the send method completed successfully:
<!--SCRIPT
mlist = new MailList ("mail.sybase.com", "elmo", "dynamo", "elmo@mail.sybase.com");
mlistitem = mlist[0];
mlistitem.Retrieve();
forward = mlistitem.Forward("jim@sybase.com");
if( !forward.Send() ) {
document.writeln( forward.GetErrorCode() );
document.writeln( forward.GetErrorInfo() );
}
-->
"mailPiece object (outgoing)".
mailPiece.Redirect( userName )
Prepares an outgoing mail piece object to be
redirected with all the appropriate properties and recipients specified
from the incoming mail piece. userName is the
internet e-mail address of the person to redirect the mail piece
to. The redirected mail piece may be edited and then sent with the
outgoing mail piece object Send
method.
Setting the smtpHost
You must either set the smtpHost
property or specify a default for it in Sybase Central before you
can forward a message using this method.
Outgoing mail piece object.
This example retrieves a mail piece and then redirects it to another user:
<!--SCRIPT
mlist = new MailList ("mail.sybase.com", "elmo", "dynamo", "elmo@mail.sybase.com");
mlistitem = mlist[0];
mlistitem.Retrieve();
mp = mlistitem.Redirect("sam@sybase.com");
if( !mp.Send() ) {
document.writeln( mp.GetErrorCode() );
document.writeln( mp.GetErrorInfo() );
}
-->
"mailPiece object (outgoing)".
mailPiece.Reply( [replyMode, includeOriginal, includeAttachments] )
Creates an outgoing mail piece from an incoming mail piece with some properties and the recipients preset.
replyMode
can
be one of:
sender"
Indicates
that the mail piece is to be sent to the address specified in the replyTo
property.
If the replyTo
property
of the original mail piece does not exist, the mail piece will be
sent to the address specified in the from
property
of the original mail piece.all"
Indicates
that the mail piece is to be sent to all recipients including the
sender.
includeOriginal
Can
be true or false. If true, the original mail piece body is included
in the body of the outgoing mail piece. The default is false.
includeAttachments
Can
be true or false. If true, all attachments to the original mail
piece are included in the outgoing mail piece. The default is false.
Setting the smtpHost
You must either set the smtpHost
property or specify a default for it in Sybase Central before you
can forward a message using this method.
Outgoing mail piece object.
This example retrieves and replies to a mail piece.
<!--SCRIPT
mlist = new MailList ("mail.sybase.com", "elmo", "dynamo", "elmo@mail.sybase.com");
mlistitem = mlist[8];
mlistitem.Retrieve();
replymp = mlistitem.Reply( "all", true );
replymp.body = replymp.body +"This is the body of the reply mail piece. It should be appended to the original mail piece body";
replymp.Send();
-->
"mailPiece object (outgoing)".
mailPiece.Retrieve( [deleteFromServer] )
Retrieves the full mail piece from the POP3 server. You must be connected to the POP3 mail server to use this method. The deleteFromServer parameter specifies whether to mark the retrieved mail piece for deletion after retrieval. The deleteFromServer parameter may be set to true or false. The default is false. If set to true, the marked mail piece is deleted from the server once you disconnect from the POP3 server.
Boolean.
This example retrieves a mail piece:
<!--SCRIPT
mlist = new MailList ("mail.sybase.com", "elmo", "dynamo", "elmo@mail.sybase.com ");
num = mlist.count
document.WriteLn("There are " + num + " messages in the mail box");
mlistitem = mlist[1];
mlistitem.Retrieve();
document.WriteLn( mlistitem.body + "\n\n" );
mlist.Disconnect();
-->
Copyright © 1999 Sybase, Inc. All rights reserved. |
![]() |