next up previous contents
Next: Properties Up: FFish Script Objects Reference Previous: addHtmlItem   Contents

SendMail Object

Description

Sends an email via Internet using the SMTP (SIMPLE MAIL TRANSFER PROTOCOL) protocol.

available: SWFKit, SWFKit Pro


Syntax

new SendMail


Parameters

None


Returns

Returns a new instance of the SendMail object.


Remarks

Using this object to send emails via Internet. If you are not familiar with the SMTP protocol then use the send method, which send an email all in one step and fires onSend events. Otherwise, you can use the command method to send an email by hand. Before using these methods, remember to set the server, port, username and password properties (username and password is used for SMTP authorization. The SendMail Object supports the login authorization). If you use the command method to send an email, you must connect to the server first.

  1. Sending an email by using the send method

    //first make an email
    var stream = new Stream("c:\\demo\\clock.html");
    var str = "";
    while (stream.pos < stream.length)
    {
        var s = stream.readLine();
        str += s;
        str += "\r\n";
    }
    stream.close();
    var mail = new Mail;
    //make the envelope
    mail.from = "someone@server.com";
    mail.replyTo = "someone@server.com";
    mail.to = "recipient@xys.com ";
    mail.subject = "A test";
    mail.cc = "someoneelse@anotherserver.com";
    mail.bcc = "anotherone@bccserver.com";
    mail.date = Date();
    mail.priority = 3;
    //make the html
    var re = new RegExp("clock.swf", "gi");
    mail.html = str.replace(re, "cid:12345");
    //load the flash movie
    mail.addHtmlItem("c:\\demo\\clock.swf", "12345");
    //send the mail
    var sender = new SendMail;
    sender.server = "a_smtp_server";
    //if need authorization, set username and password
    sender.username = "username";
    sender.password = "passowrd";
    sender.send(mail);
    

  2. Sending an email by using the command method

    var sender = new SendMail;
    sender.server = " a_smtp_server ";
    sender.username = "username";
    sender.password = "password";
    sender.connect();
    sender.command("HELO" + sender.username + "\r\n");
    sender.command("MAIL FROM:" + mail.from + "\r\n");
    sender.command("RCPT TO:" + mail.to + "\r\n");
    sender.command("DATA\r\n");
    sender.write(mail.asText());
    sender.command("\r\n.\r\n");
    sender.close();
    

  3. Handling an onSend event

    sender.onSend = function (type, msg)
    {
        trace(msg);
    }
    sender.send(mail);
    




Subsections
next up previous contents
Next: Properties Up: FFish Script Objects Reference Previous: addHtmlItem   Contents
Copyright ©2000-2007 Shanghai TopCMM Software Technologies. All Rights Reserved.