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.
| 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:
Internet Assigned Numbers Authority - Wikipedia, the free encyclopedia