If you want to know how to get e-mail message.
Please refer to HERE.

private	function messageHandler(e:POP3MessageEvent):void{
	var msg:MimeMessage = e.getMimeMessage();
	//  attachmentChildren are only parts has attachments files.
	//  Don't need to check all children to extract files

	var attaches:Array = msg.attachmentChildren;
	if(attaches.length > 0){
		for each(var attach:MimeBodyPart in attaches){
			if(attach is MimeBinaryPart){
				var binPart:MimeBinaryPart = attach as MimeImagePart;
				var bytes:ByteArray = attach.bodyByteArray;

				//  v0.5 and less than r69 version has BUG !!
				//  binPart.getHeader("Content-Disposition"); is both available

				var contentDisposition:MimeHeader = binPart.contentDisposition;

				if(contentDisposition){
					var filename:String = contentDisposition.getParameter("filename");
					filename = MimeUtils.decodeMimeHeader(filename);
					log.debug("Filename => " + filename );

					//  save Desktop directory, plese change following codes as you like

					var file:File =	File.desktopDirectory.resolvePath(filename);
					var fs:FileStream = new	FileStream();
					fs.open(file,FileMode.APPEND);
					fs.writeBytes(bytes);
					fs.close();
				}
			}
		}
	}
}

Related Posts

8 Responses to “airxmail: How to get mail attachemnt files”

  • Alex より:

    Hi. Can somebody help me? I want to get some data about attachment file such as size and type(extention) of file without message loading.

  • coltware より:

    Hi Alex

    If you want to use POP3 protocol, you can NOT. It is protocol limitation.
    If you want to use IMAP4 protocol, IMAP4 support this, but airxmail doen’t support yet.

    But you can make your own code for that.

    Please refer to IMAP4 BODY command and BODY STRUCTURE command.

    At first, you make your subclass of IMAP4Command.
    Then please call
    IMAP4Client.execCommand()

    If you want to know how to make subclass of IMAP4Command
    Please refere to following code
    IMAP4 FETCH Command

  • Alex より:

    OK. Thank you for the informative and quick answer.

  • Philipp より:

    Hi,
    I try to save the attachmend in the email,
    when i save the complete MimeMessage as an “.eml” i can open it with e.g. Outlook.
    But i dont find the Bytes of the Attachment.
    The Length of bodyByteArray and attachmendChilden is 0
    but Why ?
    Is the Attachment in an Different Array ?

    Sorry for my bad english.

  • coltware より:

    Hi philipp

    > when i save the complete MimeMessage as an “.eml” i can open it with e.g. Outlook.

    How do you parse e-mail message ?
    What is “.eml” file ?

    So please check these points.

    Check1 )
    Can you read main text message in airxmail ?

    Check2 )
    Can you find attachment part in your “.eml” file ?
    (using text viewer as you like )

    Every think is OK and
    ff you can show me the “.eml” file and your program,
    Please send me e-mail.

  • Konstantin より:

    Is it possible to get the orientation of an jpg-email-attachment. When I send an image from iPhone it is displayed in gmail correctly, but in my flex-app it’s upside down (apparently because it was shot this way)…
    Thanx a lot for your help – your api is great! :)

  • Konstantin より:

    Hi coltware,
    is it possible to (re)open a specific email from the mailbox?
    Currently I am using
    “client.addEventListener(POP3ListEvent.POP3_RESULT_UIDL,result_uidl);
    client.addEventListener(POP3MessageEvent.POP3_MESSAGE,result_message);”
    from your pop3 example code. Whicht loads all new email (since my last call) at once.
    If there are a lot/large attachments the app stands still for some while to process.

    Is it possible to load for instance all new “email-IDs”, store them and ask for a specific email according to its “eMail-ID” later? How would this code look like. Which function call(s) would I have to make?
    Any advice apreciated VERY much!!! ;)
    Thank you!

  • Konstantin より:

    Forget my (stupid) post from earlier – it’s all in your code! THANK YOU, I love it! ;)

Leave a Reply

Spam protection by WP Captcha-Free

RSS
Add to Google
2010年11月
« 8月   12月 »
 123456
78910111213
14151617181920
21222324252627
282930