public class EmailAttachmentBuilder
extends java.lang.Object
EmailAttachment creation.| Modifier | Constructor and Description |
|---|---|
protected |
EmailAttachmentBuilder()
Only allow instantiation from
EmailAttachment class |
| Modifier and Type | Method and Description |
|---|---|
EmailAttachment<javax.mail.util.ByteArrayDataSource> |
buildByteArrayDataSource()
Creates
EmailAttachment. |
EmailAttachment<javax.activation.FileDataSource> |
buildFileDataSource(java.lang.String messageId,
java.io.File attachmentStorage)
Creates
EmailAttachment. |
EmailAttachmentBuilder |
content(byte[] bytes)
Uses
null contentType. |
EmailAttachmentBuilder |
content(byte[] bytes,
java.lang.String contentType)
Creates new
ByteArrayDataSource and then calls content(DataSource). |
EmailAttachmentBuilder |
content(java.io.File file)
Creates new
FileDataSource and then calls content(DataSource) |
EmailAttachmentBuilder |
content(java.io.InputStream inputStream,
java.lang.String contentType)
Creates new
ByteArrayDataSource and then calls content(DataSource). |
EmailAttachmentBuilder |
content(java.lang.String fileName) |
<T extends javax.activation.DataSource> |
content(T dataSource)
Sets the
DataSource. |
EmailAttachmentBuilder |
contentId(java.lang.String contentId)
Sets content ID.
|
EmailAttachmentBuilder |
embeddedMessage(EmailMessage targetMessage)
Sets target
EmailMessage. |
EmailAttachmentBuilder |
inline(boolean isInline)
Sets whether
EmailAttachment is inline. |
EmailAttachmentBuilder |
name(java.lang.String name)
Sets file name.
|
protected java.lang.String |
resolveContentType(java.lang.String contentType)
Resolves content type from all data.
|
protected EmailAttachmentBuilder |
setContentIdFromNameIfMissing()
Set content ID if it is missing.
|
protected EmailAttachmentBuilder()
EmailAttachment classpublic EmailAttachmentBuilder name(java.lang.String name)
name - File name to set.public EmailAttachmentBuilder contentId(java.lang.String contentId)
contentId - content ID of EmailAttachment.public EmailAttachmentBuilder inline(boolean isInline)
EmailAttachment is inline.isInline - true for inline.public EmailAttachmentBuilder embeddedMessage(EmailMessage targetMessage)
EmailMessage.targetMessage - Target EmailMessage.public <T extends javax.activation.DataSource> EmailAttachmentBuilder content(T dataSource)
DataSource. Common DataSources include ByteArrayDataSource and
FileDataSource.dataSource - DataSourcepublic EmailAttachmentBuilder content(java.io.InputStream inputStream, java.lang.String contentType) throws java.io.IOException
ByteArrayDataSource and then calls content(DataSource).inputStream - InputStreamcontentType - content type from EmailAttachment.java.io.IOException - if ByteArrayDataSource cannot be created from InputStreamcontent(DataSource)public EmailAttachmentBuilder content(byte[] bytes, java.lang.String contentType)
ByteArrayDataSource and then calls content(DataSource).bytes - array of bytescontentType - content type from EmailAttachment.content(DataSource)public EmailAttachmentBuilder content(byte[] bytes)
null contentType.content(byte[], String)public EmailAttachmentBuilder content(java.io.File file)
FileDataSource and then calls content(DataSource)file - Filecontent(DataSource)public EmailAttachmentBuilder content(java.lang.String fileName)
fileName - String representing file name.content(File)public EmailAttachment<javax.mail.util.ByteArrayDataSource> buildByteArrayDataSource() throws MailException
EmailAttachment.EmailAttachment.MailException - if issue with DataSource.public EmailAttachment<javax.activation.FileDataSource> buildFileDataSource(java.lang.String messageId, java.io.File attachmentStorage) throws MailException
EmailAttachment.EmailAttachment.MailException - if issue with DataSource.protected EmailAttachmentBuilder setContentIdFromNameIfMissing()
contentId(String)protected java.lang.String resolveContentType(java.lang.String contentType)
contentType - Content type if we know it. null is fine to use.Copyright © 2003-present Jodd Team