How to specify dynamic transactional images in the transactional email request

In the web service request for transactional email, specify dynamic transactional images as email attachments. Attachment size requirements for other types of attachments also apply to dynamic transactional images. Each dynamic transactional image cannot exceed 1 Mb and the total of all attachments cannot exceed 2 Mb.

An image label can appear multiple times in an email but it must appear only once in the SOAP request. If you use the same label in multiple attachments.

Use the attachments parameter to specify dynamic transactional images as attachments to transactional email. In the attachments parameter, the value for thelabel attribute is the image label that is defined in the email document.

Consider the following example of how to configure the attachments parameter to specify dynamic transactional images. Assume that you want to send a transactional email that includes an entrance pass to an upcoming customer conference and a map with directions. You must configure two attachments in the web service request. The first attachment is a QR code that admits the recipient to the conference. The second attachment is a map that provides driving directions from the physical address currently on file for the customer. The following example illustrates how the attachments portion of the web service request might look.

// Configure attachments In this example, there are two attachments:
// QRblock and MAP_site
Attachment[] attachments = new Attachment[2];

//This is the first of the two attachments
// Load the attachment data from the file system 
     using a data source
FileDataSource QRdataSource = new FileDataSource(new File("C:\\QR.png"));
DataHandler QRhandler = new DataHandler(QRdataSource);
Base64Binary QRattachmentBinary = new Base64Binary();
attachmentBinary.setBase64Binary(QRhandler);
ContentType_type0 QRContentType = new ContentType_type0();
QRContentType.setContentType_type0(QRhandler.getContentType());

// specify the content type for the attachment
QRattachmentBinary.setContentType(QRContentType);

// Add the attachment
Attachment QRblock = new Attachment();
QRblock.setFileName("QR.png");
QRblock.setLabel("PremiumTix_QR");
QRblock.setFileContent(QRattachmentBinary);

//This is the second of the two attachments
// Load the attachment data from the file system 
      using a data source
FileDataSource MAPdataSource = new FileDataSource(new File("C:\\SiteMap.png"));
DataHandler MAPhandler = new DataHandler(MAPdataSource);
Base64Binary MAPattachmentBinary = new Base64Binary();
MAPattachmentBinary.setBase64Binary(MAPhandler);
ContentType_type0 MAPContentType = new ContentType_type0();
MAPContentType.setContentType_type0(MAPhandler.getContentType());

// specify the content type for the attachment
MAPattachmentBinary.setContentType(MAPContentType);

// Add the attachment
Attachment MAP_site = new Attachment();
MAP_site.setFileName("SiteMap.png");
MAP_site.setLabel("Map_directions");
MAP_site.setFileContent(MAPattachmentBinary);
 

// Set the attachment array
attachments[0] = QRblock;
attachments[1] = MAP_site;