Chapter 3 DynaScript Predefined Objects
This object is a mail piece received by a specific recipient, which is being held on a mail server. The mailList object is a list of incoming mail piece objects representing mail accessible via a POP3 server.
To use an incoming mail piece property:
mailPiece.propertyName
To use an incoming mail list method:
mailPiece.MethodName( parameter )
Each incoming mail piece is represented by an incoming mail piece object. You can manipulate the object to display the different parts of the incoming mail piece.
This example retrieves a mail piece (mlistitem) and displays its subject, body, and attachments:
<!--SCRIPT mlist = new MailList ("mail.sybase.com", "elmo", "secret", "elmo@mail.sybase.com "); mlistitem = mlist[1]; mlistitem.Retrieve(); document.WriteLn( mlistitem.subject ); document.WriteLn( mlistitem.body ); document.WriteLn( mlistitem.attachments ); mlist.Disconnect(); -->
mailPiece.attachments
This property is read-only.
A list of attachments contained with the incoming mail piece.
List of attachment objects
This example displays the names of all attachments in incoming mail piece number 7:
<!--SCRIPT mlist = new MailList ("mail.sybase.com", "elmo", "dynamo", "elmo@mail.sybase.com"); mlistItem = mlist[7] lmilstItem.Retrieve() for ( i in mlistItem.attachment );{P document.WriteLn( mlistitem.attachments[i].name; } mlist.Disconnect(); -->
mailPiece.body
This property is read-only.
The body or content text of the incoming mail piece. This property is available only after doing a Retrieve.
String
This example displays the body of an incoming mail piece:
<!--SCRIPT mlist = new MailList ("mail.sybase.com", "elmo", "dynamo", "elmo@mail.sybase.com"); mlistitem = mlist[1]; mlistitem.Retrieve(); document.WriteLn( mlistitem.body ); mlist.Disconnect(); -->
mailPiece.from
This property is read-only.
The person from whom the mail piece originated.
String
This example display the address from which the mail piece originated:
<!--SCRIPT mlist = new MailList ("mail.sybase.com", "elmo", "dynamo", "elmo@mail.sybase.com"); mlistitem = mlist[4]; document.WriteLn( mlistitem.from ); mlist.Disconnect(); -->
mailPiece.headers
This property is read-only.
The ARPA message headers. These are the unprocessed header fields from the mail piece.
String
This example displays the headers:
<!--SCRIPT mlist = new MailList ("mail.sybase.com", "elmo", "dynamo", "elmo@mail.sybase.com"); mlistitem = mlist[4]; document.WriteLn( mlistitem.headers ); mlist.Disconnect(); -->
mailPiece.recipients
This property is read-only.
The recipients of the incoming mail piece.
List of recipient objects
This example displays a list of the recipients for the incoming mail piece:
<!--SCRIPT mlist = new MailList ("mail.sybase.com", "elmo", "dynamo", "elmo@mail.sybase.com "); mlistitem=mlist[2]; mlistitem.Retrieve(); for (i in mlistitem.recipients ){ document.WriteLn(mlistitem.recipients[i]); } mlist.Disconnect(); -->
mailPiece.replyTo
This property is read-only.
Who the recipient of the mail piece should reply to. This is a list of recipient objects. If this field exists, the reply method responds to the recipients listed here instead of to addresses specified in the from field.
List of recipient objects
This example displays the address of the individual
to whom the mail piece is sent if the Reply
method
is used. If the replyTo
property
is null, the mail piece is sent to the address held in the from
property
<!--SCRIPT mlist = new MailList ("mail.sybase.com", "elmo", "dynamo", "elmo@mail.sybase.com "); mlistitem=mlist[2]; mlistitem.Retrieve(); for (i in mlistitem.replyTo ){ document.WriteLn(mlistitem.replyTo[i]); } mlist.Disconnect(); -->
mailPiece.sender
This property is read-only.
The address from where the mail piece was sent. This is not necessarily the same address as the from field (in the case where a mail piece has been redirected).
String
This example indicates if the mail piece was sent directly by the author or by a "sender":
<!--SCRIPT mlist = new MailList ("mail.sybase.com", "elmo", "dynamo", "elmo@mail.sybase.com "); mlistitem = mlist[2]; mlistitem.Retrieve(); if (mlistitem.sender(true)){ document.WriteLn("This mail piece was sent from " + mlistitem.sender + "for " + mlistitem.from); }else{ document.WriteLn("There was no sender property on this mail piece"); } mlist.Disconnect(); -->
mailPiece.size
This property is read-only.
The size (bytes) of the incoming mail piece.
Integer
This example displays the size of the mail piece:
<!--SCRIPT mlist = new MailList ("mail.sybase.com", "elmo", "dynamo", "elmo@mail.sybase.com"); mlistitem = mlist[9]; mlistitem.Retrieve(); document.WriteLn( "size: " + mlistitem.size ); mlist.Disconnect(); -->
mailPiece.subject
This property is read-only.
The subject of the incoming mail piece.
String
This example displays the subject of the mail piece:
<!--SCRIPT mlist = new MailList ("mail.sybase.com", "elmo", "dynamo", "elmo@mail.sybase.com"); mlistitem = mlist[1]; document.WriteLn( mlistitem.subject ); mlist.Disconnect(); -->
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.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.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.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.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.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:
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.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.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 © 2001 Sybase, Inc. All rights reserved. |
![]() |