This is a sample code to send html mail for airxmail(actionscript 3 smtp/pop3 library).

Flex SDK 3.4 or more
AIR 1.5 or more
airxmail library ( download )

related links:
Basic usage of airxmail

sample code

var contentType:ContentType = ContentType.MULTIPART_ALTERNATIVE;
var mimeMsg:MimeMessage = new MimeMessage(contentType);
var from:INetAddress = new INetAddress();
from.personal = "Sample User";
from.address = this.fromEmail;
var toAddr:INetAddress = new INetAddress(this.toEmail,"Customer");
// set mail subject
mimeMsg.setSubject("this is first my message");
mimeMsg.setTextBody("this is multipart message");
// TextPart
var partText:MimeTextPart = mimeMsg.createTextPart();
partText.setText("this is plain body");
// HtmlPart
var partHtml:MimeTextPart = mimeMsg.createTextPart();
partHtml.setHtmlText("<html><body><b>THIS IS HTML BODY</b></body></html>");

There are 3 points that you should care in the source code.

1. multipart message

var contentType:ContentType = ContentType.MULTIPART_ALTERNATIVE;
var mimeMsg:MimeMessage = new MimeMessage(contentType);

Default content type is ‘text/plain’.

2. make child part for text and html

var partText:MimeTextPart = mimeMsg.createTextPart();

3. set body text ( or html text )

MimeTextPart has 2 property to set the body text;

  • setText — set plain text(text/plain)
  • setHtmlText – set html text(text/html)

Next time: how to make e-mail with attachemnt files.

Related Posts

15 Responses to “actionscript 3: how to send html email ( use airxmail library )”

  • Ben Arent より:

    Hi Coltware,

    Thanks for building Airxmail. I’m testing it today, but always get it into my junk mail. Is there anyway to overcome this?


  • coltware より:

    Thanks ben,

    >but always get it into my junk mail.
    That is so difficult to know the reason for me.
    Because all e-mail environments I know is japan’s environments.

    Anyway I can check to try same or similar way you did.
    Please let me know your e-mail client software or web mail service.

  • Andros より:

    I get the error:

    1046: Type was not found or was not a compile-time constant: ContentType.

    1180: Call to a possibly undefined method MimeBinaryPart.

    I am trying this in Flash IDE CS5

  • coltware より:

    Hi Andros

    Please let me know the environment you use more.
    I don’t use Flash IDE.
    So It is difficult to expect the reason that related Flash IDE.

    You mean you can’t find ContentType and you got compile error … ?

    >1180: Call to a possibly undefined method MimeBinaryPart.
    I don’t understand the meaning …

    What does ‘1046’ and ‘1180’ stand for ?
    Is it line number ?

  • Hello, thanks a lot for building such a great libs.
    However i got a little problem, perhaps it’s my misunderstanding, but how do i get htmlText from receveid email (trough imap) bodyText seems html striped (at least with gmail email)

  • coltware より:

    Thanks for comments and sorry for the delay of the answer.

    I can expect your situation and the reason.
    But I can’t have the positive proof yet.
    And I don’t have the English skill to express my vague idea.

    So I’ll check my test environment, and reply the answer in a few days.
    Please wait.

  • coltware より:

    I wrote the posts that show to get html text from email.

    Please see it.

  • Jahangir より:

    Hi Coltware,
    First of all thank you for your awesome work! I am new to Actionscript programming. I built a small app using Flash Builder 4.5.1 that suppose to collect information and send email to an specific email address.

    I have added your SWC file in the library(properties>Flex Build Path > Library Path). But whenever I try to debug it i get “Source not found” error at the very first line(var sender:SMTPSender = new SMTPSender()).

    Your help will be really really appreciated.

  • coltware より:

    Hi Jahangir

    So sorry , reply message was late.

    Please download source archive file like a “”
    or checkout source code from google code.

  • julifos より:

    Yep, seems something is missing both in the SVN and the zip file, like the “job” and “utils” folders… (?)

    import com.coltware.airxlib.job.SocketJobSync;
    import com.coltware.airxlib.utils.StringLineReader;

  • julifos より:

    I think I got it. I don’t know how I did it, but I think you need some of these as well:

    And the flex framework (for the mx.* stuff):

    That is how I was able to compile in the Flash IDE and send the first test email from a sample AIR app 😉

  • julifos より:

    No, the job, log and utils SWC are in the SVN, check it out (and sorry for the double-posting)

  • coltware より:

    Hi julifos

    airxlib is common library for my other library and application.
    So I split the project.

    Then if you want to see airxlib sources, as you know , you can download on

    But most of user can swc files in libs directory on airxmail project svn.
    Or please use file.

  • Steave より:

    Hi Coltware,
    First of all thank you for your great work!
    In the Development Environment of Flex 4.1, it works fine .But while using in Development Environment of Flex 3.5 , i get Error like

    1044: Interface method callInContext in namespace mx.core:IFlexModuleFactory not implemented by class

    1044: Interface method get isProxy in namespace mx.managers:ISystemManager not implemented by class

    Any idea of what I should try ?


Leave a Reply

Spam protection by WP Captcha-Free

Add to Google
    5月 »