Posts Tagged ‘attachment’

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

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

related links:
Basic usage of airxmail
How to send html mail.

sample code

use MimeBinaryPart ( application/octet-stream )

basic usage
var contentType:ContentType = ContentType.MULTIPART_MIXED;
var mimeMsg:MimeMessage = new MimeMessage(contentType);
:
:
var filePart:MimeBinaryPart = new MimeBinaryPart();
filePart.setAttachementFile(File.desktopDirectory.resolvePath("image.jpg"),"attachemnt-image.jpg");
mimeMsg.addChildPart(filePart);

sender.send(mimeMsg);
sender.close();
how to change content-type
var filePart:MimeBinaryPart = new MimeBinaryPart()
filePart.contentType.setMainType("image");
filePart.contentType.setSubType("jpeg");

Note: MimeImagePart is image/xxxx part.

filePart:MimeImagePart = new MimeImagePart();
filePart.setAttachementFile(file,"attachemnt-image.jpg");   // --> image/jpeg
//filePart.setAttachementFile(file,"attachemnt-image.gif");   // --> image/gif
RSS
Add to Google
2017年3月
« 2月    
 1234
567891011
12131415161718
19202122232425
262728293031