Chapter 3 DynaScript Predefined Objects


mail piece methods (incoming)

The incoming mail piece object has these methods:

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 © 1999 Sybase, Inc. All rights reserved.