You have to care 2 type of content type if you want to get html part of e-mail message.

1 ) text/html
2 ) multipart/alternative

1 ) text/html

In this case, you can get html content very easily.
The mime message only has one body part.

private function handleMessage(event:IMessageEvent):void{
  var msg:MimeMessage = event.getMimeMessage();
  var htmlText:String = msg.bodyText;
}
2 ) multipart/alternative

This case is slightly harder than case 1.
But airxmail support to access to child part using findParts method.

var parts:Array = msg.findParts("text/html");
  if(parts.length > 0){
    var htmlText:String = MimeBodyPart(parts[0]).bodyText;
  }
}

Typically, text/html part is the only one.
So I think you don’t need to check first text/html part.

see source code

MimeMessage.findPart

Related Posts

3 Responses to “airxmail:How to get html part of e-mail message”

  • Thanks a lot, i got the idea now.

    I’ve created some commands that i needed (append, copy and expunge) i guess it’s nothing really interesting for you however if you want it send me an email.

  • coltware より:

    Thank you so much.
    I didn’t check IMAP append command in detail.
    So I didn’t create yet.

    If you give it to me,I’m very happy.

    I’ll send you e-mail later.
    Thank you.

  • No problem, however just a little question, i want to serialize mail and put them in base, i did :

    [code]
    public static function messageToString(message:MimeMessage):String {
    var bytes:ByteArray = new ByteArray();
    message.writeHeaderSource(bytes);
    bytes.writeUTFBytes(“\r\n”);
    message.writeBodySource(bytes);
    bytes.position = 0;
    return bytes.readUTFBytes(bytes.bytesAvailable);
    }

    [/code]
    for serialization process( i get it from somewhere in your code), how can i reparse it after ?

Leave a Reply

Spam protection by WP Captcha-Free

RSS
Add to Google
2011年4月
« 2月   5月 »
 12
3456789
10111213141516
17181920212223
24252627282930