import SWFKit.*;
var mail = new Mail;
mail.from = "someone@swfkit.com";
mail.to = "support@some.com;sales@some.com";
mail.subject = "This is an Email";
mail.text = "Hello, SWFKit!";
mail.date = (new Date).toString();
mail.addAttachment("c:\\myfile.mp3");
Then you can use the SendMail object to send the email out.
function onSendIt(type, msg)
{
_root.strace("type is: " + type + " " + msg);
if (!SWFKit.Global.processMsg()) return false;
return true;
}
var sm = new SendMail;
sm.server = "myserver";
sm.port = 25;
sm.username = "myname";
sm.password = "mypassword";
sm.setEventHandler("onSend", onSendIt);
sm.send(mail);
To receive emails, you would have to use the RecvMail object.
import SWFKit.*;
// The event handler of the RecvMail object
function onRecieve(type, msg)
{
_root.strace(msg);
if (!SWFKit.Global.processMsg()) return false;
return true;
}
var rm = new RecvMail;
rm.server = "myserver";
rm.port = 110;
rm.username = "myname";
rm.password = "mypassword";
// Connect to the POP3 server
rm.connect();
rm.setEventHandler("onRecv", onRecieve);
// Get email count on the POP3 server
var count = rm.list();
_root.strace(count);
if (count.length > 0)
{
// Receive only the first 10 emails
for (var i = 1; i <= 10; i++)
{
// Receive the ith email, it returns
// a Mail object
var mail = rm.retr(i);
if (mail != null)
{
_root.strace(mail);
_root.strace(mail.text);
if (mail.attachmentCount > 0)
{
// Extract the attachments
...
}
}
}
}
rm.quit();
rm.close();