Chapter 3 DynaScript Predefined Objects


mailPiece object (incoming)

Object

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.

Syntax

To use an incoming mail piece property:

mailPiece.propertyName

To use an incoming mail list method:

mailPiece.MethodName( parameter ) 

Description

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.

Example

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();
-->

See also

"attachment object"

"mailList object"

"mailPiece object (outgoing)"

"recipient object"

attachments property

Syntax

mailPiece.attachments

Attributes

This property is read-only.

Description

A list of attachments contained with the incoming mail piece.

Return

List of attachment objects

Example

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();
-->

See also

"mailList object"

body property

Syntax

mailPiece.body 

Attributes

This property is read-only.

Description

The body or content text of the incoming mail piece. This property is available only after doing a Retrieve.

Return

String

Example

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();
-->

See also

"mailList object"

"mailPiece object (outgoing)"

from property

Syntax

mailPiece.from 

Attributes

This property is read-only.

Description

The person from whom the mail piece originated.

Return

String

Example

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();
-->

See also

"mailList object"

headers property

Syntax

mailPiece.headers 

Attributes

This property is read-only.

Description

The ARPA message headers. These are the unprocessed header fields from the mail piece.

Return

String

Example

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();
-->

See also

"mailList object"

"mailPiece object (outgoing)"

recipients property

Syntax

mailPiece.recipients 

Attributes

This property is read-only.

Description

The recipients of the incoming mail piece.

Return

List of recipient objects

Example

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();
-->

See also

"mailList object"

"mailPiece object (outgoing)"

replyTo property

Syntax

mailPiece.replyTo 

Attributes

This property is read-only.

Description

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.

Return

List of recipient objects

Example

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();
-->

See also

"mailList object"

"mailPiece object (outgoing)"

sender property

Syntax

mailPiece.sender 

Attributes

This property is read-only.

Description

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).

Return

String

Example

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();
-->

See also

"mailList object"

"mailPiece object (outgoing)"

size property

Syntax

mailPiece.size 

Attributes

This property is read-only.

Description

The size (bytes) of the incoming mail piece.

Return

Integer

Example

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();
-->

See also

"mailList object"

"mailPiece object (outgoing)"

subject property

Syntax

mailPiece.subject 

Attributes

This property is read-only.

Description

The subject of the incoming mail piece.

Return

String

Example

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();
-->

See also

"mailList object"

"mailPiece object (outgoing)"

Delete method

Syntax

mailPiece.Delete( )

Description

Marks a mail piece for deletion. The mail piece is not actually deleted until the POP3 server is disconnected.

Return

Boolean

Example

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();

See also

"mailList object"

"mailPiece object (outgoing)"

Forward method

Syntax

mailPiece.Forward( userName [, includeAttachments] )

Description

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:

Note  

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.

Return

Outgoing mail piece object

Example

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();
-->

See also

"mailList object"

"mailPiece object (outgoing)"

GetErrorCode method

Syntax

mailPiece.GetErrorCode( )

Description

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.

Return

Integer

Example

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() );
   }
-->

See also

"mailList object"

"mailPiece object (outgoing)"

GetErrorInfo method

Syntax

mailPiece.GetErrorInfo( )

Description

Returns a string containing an error message. The error generated is either a reply from the POP3 server or from PowerDynamo.

Return

String

Example

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() );
   }
-->

See also

"mailList object"

"mailPiece object (outgoing)"

Redirect method

Syntax

mailPiece.Redirect( userName )

Description

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.

Note  

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.

Return

Outgoing mail piece object

Example

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() );
   }
-->

See also

"mailList object"

"mailPiece object (outgoing)"

Reply method

Syntax

mailPiece.Reply( [replyMode, includeOriginal, includeAttachments] )

Description

Creates an outgoing mail piece from an incoming mail piece with some properties and the recipients preset.

Note  

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.

Return

Outgoing mail piece object

Example

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();
-->

See also

"mailList object"

"mailPiece object (outgoing)"

Retrieve method

Syntax

mailPiece.Retrieve( [deleteFromServer] )

Description

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.

Return

Boolean

Example

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();
-->

See also

"mailList object"

"mailPiece object (outgoing)"

 


Copyright © 2001 Sybase, Inc. All rights reserved.