Chapter 9 PowerDynamo Mail Support
In this section you will create a simple mail application which may be used to send and view mail for a number of users. To use this simple application, you must have access to a POP3 mail server and a SMTP host.
Create the following templates in your PowerDynamo Web site:
mailMain.stm
<HTML>
<TITLE>mailMain.stm</TITLE>
<BODY>
<H1>Dynamo 3.5 Mail</H1>
<a href=mailComp.stm>Compose a piece of mail</a><BR>
<a href=mailListMain.stm>List mail in the mail box</a>
</BODY>
</HTML>
<HTML>
<TITLE>mailcomp.stm</TITLE>
<BODY>
<h1>Sending an email
<form action=mailSend.stm>
<table>
<tr><th align=left>From:</th>
<td><input type=input name=from size=30 maxlength=30 value=elmo@sybase.com></td></tr>
<tr><th align=left>To:</th>
<td><input type=input name=to size=30 maxlength=30 value=george@mailsrv.sybase.com></td></tr>
<tr><th align=left>Host:</th>
<td><input type=input name=host size=30 maxlength=40 value=boot.sample.com></td></tr>
<tr><th align=left>Subject:</th>
<td><input type=input name=subject size=50 maxlength=60 value='testing stuff'></td></tr>
<tr><th align=left>Body:</th>
<td><textarea name=body rows=5 cols=50> Enter your message here... </textarea></td></tr>
</table>
<input type=submit value=Send>
<input type=submit value=Cancel>
</form>
</BODY>
</HTML>
For more information on setting the host see the "smtpHost property" in PowerDynamo Reference.
For more information on the outgoing mail, see "The mail piece object (outgoing)" in PowerDynamo Reference.
<HTML>
<TITLE>mailsend.stm</TITLE>
<BODY>
<H1>Dynamo 3.5 Mail</H1>
<!--script
var parm = document.value;
if (parm.action="Send") {
var mp = new MailPiece();
mp.subject = parm.subject;
mp.from = parm.from;
mp.body = parm.body;
mp.smtpHost=parm.host;
mp.AddRecipient( parm.to, "to" );
if ( !mp.Send() ) {
document.writeln( mp.GetErrorCode() );
document.writeln( mp.GetErrorInfo() );
} else {
document.writeln("Sent!");
}
}
-->
<a href="mailMain.stm">click here to return to the mail menu</a>
</BODY>
</HTML>
For more information on error checking, see "The mail piece object (outgoing)" in PowerDynamo Reference.
<HTML>
<TITLE>mailListMain.stm</TITLE>
<BODY>
<H1>Dynamo 3.5 display of mail in the mailbox</H1>
<form action='mailList.stm' method=post>
<table>
<tr><th align=left>Mail Server:</th>
<td><input type=text name=mailServer size=30 value=mailsrv.sybase.com></td></tr>
<tr><th align=left>User Name:</th>
<td><input type=text name=username size=30 value=george></td></tr>
<tr><th align=left>Password:</th>
<td><input type=password name=passwd size=30 value=dynamo></td></tr>
</table>
<input type=submit name=action value=Logon>
</form>
</BODY>
</HTML>
<HTML>
<TITLE>mailList.stm</TITLE>
<BODY>
<H1>Dynamo 3.5 Mail</H1>
<!--script
var parm = document.value;
var mlist = new MailList (parm.mailServer, parm.username, parm.passwd, parm.username+'@'+parm.mailServer, false);
if (mlist.GetErrorCode()>899) {
document.writeln(mlist.GetErrorCode());
document.writeln(mlist.GetErrorInfo());
} else {
var num = mlist.count
document.WriteLn("There are " + num + " messages in the mail box<br>");
document.writeln("\n&
<table border>\n&
<tr><th>From</th><th>Subject</th><th>Body</th></tr>");
for (i in mlist) {
mlist[i].Retrieve();
document.writeln("\n&
<tr><td>"+mlist[i].from+"</td>\n&
<td>"+mlist[i].subject+"</td>\n&
<td>"+mlist[i].body+"</td></tr>");
}
document.writeln("\n&
</table>");
}
mlist.Disconnect();
-->
<BR>
<a href=mailMain.stm>Return to the main menu</a>
</BODY>
</HTML>
For information on the incoming mail piece and its methods see "The mail piece object (incoming)" in PowerDynamo Reference.
Once you have created these files, you can start your mail application by opening mainMail.stm in a browser.
Copyright © 1999 Sybase, Inc. All rights reserved. |