cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to add file attachments to email

How to add file attachments to email

 

Adding file attachments to email

Here is a code snippet which adds file attachments to emails. 

 

For this we use the EmailFileAttachement object and add it to the EmailOptions when sending.

 

EmailTemplate emailTemplate = context.getObject( EmailTemplate.class, "some email template" );

 

EmailOptions emailOptions = new EmailOptions();

 

// This fictional method would return a String to

// set the fileName of the attachment.

String fileName = getFileName();

 

// This fictional method would return a byte[] to

// set the data of the attachment.

byte[] fileData = generateCsvFile();

 

EmailFileAttachment attachment = new EmailFileAttachment( fileName, EmailFileAttachment.MimeType.MIME_CSV, fileData );

emailOptions.addAttachment( attachment );


context.sendEmailNotification( emailTemplate, emailOptions );

 

Note: This was written for IdentityIQ 6.2. Other versions may vary.

 

Supported MimeTypes

EmailFileAttachement
MimeType
Standard MIME Type
MIME_CSV text/csv
MIME_JAR application/java-archive
MIME_HTML text/html
MIME_OCTET application/octet-stream
MIME_PDF application/pdf
MIME_PLAIN text/plain
MIME_PS application/postscript
MIME_RICH text/richtext
MIME_WORD application/msword
MIME_ZIP application/zip

 

For more information, see:

Media Types

Internet Assigned Numbers Authority - Wikipedia, the free encyclopedia        

Version history
Revision #:
3 of 3
Last update:
‎May 17, 2026 01:21 AM
Updated by: