@FullyTested public final class EmailMessageTextAttachmentBuilderImp extends Object implements EmailMessageTextAttachmentBuilder
JavaMailSessionBuilderFactory.INSTANCE| Constructor and Description |
|---|
EmailMessageTextAttachmentBuilderImp(EmailMessageBuilder parentBuilder) |
| Modifier and Type | Method and Description |
|---|---|
EmailMessageTextAttachmentBuilder |
attachmentFileName(String attachmentFileName)
This is the most common attachment type.
|
EmailMessageTextAttachmentBuilder |
attachText(String text,
EmailMessageAttachmentTextNewLine newLine,
IsEmptyAllowed isEmptyAllowed)
Converts text new-lines (if necessary), then adds new attachment to the parent builder.
|
EmailMessageTextAttachmentBuilder |
attachTextFile(File filePath,
Charset fileCharset,
EmailMessageAttachmentTextNewLine newLine,
IsEmptyAllowed isEmptyAllowed)
Immediately reads the contents of the file as text, converts text new-lines (if necessary),
then adds new attachment to the parent builder.
|
EmailMessageTextAttachmentBuilder |
attachTextInputStream(InputStream inputStream,
Charset inputStreamCharset,
EmailMessageAttachmentTextNewLine newLine,
IsEmptyAllowed isEmptyAllowed)
Immediately reads the contents of the
InputStream as text, converts text new-lines (if necessary),
then adds new attachment to the parent builder. |
EmailMessageTextAttachmentBuilder |
customTextMimeSubType(String customTextMimeSubType)
RARE: Sets the text MIME sub-type to a custom value.
|
EmailMessageTextAttachmentBuilder |
inline()
RARE: Sets the attachment type to
EmailMessageAttachmentType.INLINE and clears the attachment file name. |
EmailMessageBuilder |
parent()
Access the parent email message builder
|
EmailMessageTextAttachmentBuilder |
textMimeSubType(TextMimeSubType textMimeSubType)
Sets the text MIME sub-type to a common value -- text or plain.
|
public EmailMessageTextAttachmentBuilderImp(EmailMessageBuilder parentBuilder)
public EmailMessageBuilder parent()
parent in interface EmailMessageTextAttachmentBuilderpublic EmailMessageTextAttachmentBuilder attachmentFileName(String attachmentFileName)
Sets the attachment type to EmailMessageAttachmentType.ATTACHMENT and sets the attachment file name.
attachmentFileName in interface EmailMessageTextAttachmentBuilderattachmentFileName - only a file name -- does not include a parent path
"log.txt"EmailMessageTextAttachmentBuilder.inline()public EmailMessageTextAttachmentBuilder inline()
EmailMessageAttachmentType.INLINE and clears the attachment file name.inline in interface EmailMessageTextAttachmentBuilderEmailMessageTextAttachmentBuilder.attachmentFileName(String)public EmailMessageTextAttachmentBuilder textMimeSubType(TextMimeSubType textMimeSubType)
For custom types, see: EmailMessageTextAttachmentBuilder.customTextMimeSubType(String).
textMimeSubType in interface EmailMessageTextAttachmentBuilderEmailMessageTextAttachmentBuilder.customTextMimeSubType(String)public EmailMessageTextAttachmentBuilder customTextMimeSubType(String customTextMimeSubType)
For common types, see EmailMessageTextAttachmentBuilder.textMimeSubType(TextMimeSubType).
customTextMimeSubType in interface EmailMessageTextAttachmentBuilderEmailMessageTextAttachmentBuilder.textMimeSubType(TextMimeSubType)public EmailMessageTextAttachmentBuilder attachTextFile(File filePath, Charset fileCharset, EmailMessageAttachmentTextNewLine newLine, IsEmptyAllowed isEmptyAllowed) throws Exception
Implementation note: Regardless of fileCharset, the text is always re-encoded using
StandardCharsets.UTF_8 before attachment. Why? In 2020, everything should be UTF-8!
attachTextFile in interface EmailMessageTextAttachmentBuilderfilePath - path to file with textfileCharset - charset used to read text from filePathnewLine - for internal emails at large corporations, EmailMessageAttachmentTextNewLine.WINDOWS is probably
most friendly towards Microsoft Windows and Microsoft Outlook users
EmailMessageTextAttachmentBuilder.inline() is used, this option may be irrelevant. Multiple tests showed the new-lines
for inline text on received emails to always be Microsoft Windows new-lines.isEmptyAllowed - normally, use IsEmptyAllowed.NOException - on I/O exception
isEmptyAllowed is IsEmptyAllowed.NO and the file is emptyEmailMessageTextAttachmentBuilder.attachTextInputStream(InputStream, Charset, EmailMessageAttachmentTextNewLine, IsEmptyAllowed),
EmailMessageTextAttachmentBuilder.attachText(String, EmailMessageAttachmentTextNewLine, IsEmptyAllowed)public EmailMessageTextAttachmentBuilder attachTextInputStream(InputStream inputStream, Charset inputStreamCharset, EmailMessageAttachmentTextNewLine newLine, IsEmptyAllowed isEmptyAllowed) throws Exception
InputStream as text, converts text new-lines (if necessary),
then adds new attachment to the parent builder.
Implementation note: Regardless of fileCharset, the text is always re-encoded using
StandardCharsets.UTF_8 before attachment. Why? In 2020, everything should be UTF-8!
attachTextInputStream in interface EmailMessageTextAttachmentBuilderinputStream - unlike most Java APIs, the input stream is closed after reading. This is the source or many hidden bugs!
InputStream.close()inputStreamCharset - charset used to read text from inputStreamnewLine - for internal emails at large corporations, EmailMessageAttachmentTextNewLine.WINDOWS is probably
most friendly towards Microsoft Windows and Microsoft Outlook users
EmailMessageTextAttachmentBuilder.inline() is used, this option may be irrelevant. Multiple tests showed the new-lines
for inline text on received emails to always be Microsoft Windows new-lines.isEmptyAllowed - normally, use IsEmptyAllowed.NOException - on I/O exception
isEmptyAllowed is IsEmptyAllowed.NO and inputStream is emptyEmailMessageTextAttachmentBuilder.attachTextFile(File, Charset, EmailMessageAttachmentTextNewLine, IsEmptyAllowed),
EmailMessageTextAttachmentBuilder.attachText(String, EmailMessageAttachmentTextNewLine, IsEmptyAllowed)public EmailMessageTextAttachmentBuilder attachText(String text, EmailMessageAttachmentTextNewLine newLine, IsEmptyAllowed isEmptyAllowed)
Implementation note: Regardless of fileCharset, the text is always re-encoded using
StandardCharsets.UTF_8 before attachment. Why? In 2020, everything should be UTF-8!
attachText in interface EmailMessageTextAttachmentBuildertext - text for attachmentnewLine - for internal emails at large corporations, EmailMessageAttachmentTextNewLine.WINDOWS is probably
most friendly towards Microsoft Windows and Microsoft Outlook users
EmailMessageTextAttachmentBuilder.inline() is used, this option may be irrelevant. Multiple tests showed the new-lines
for inline text on received emails to always be Microsoft Windows new-lines.isEmptyAllowed - normally, use IsEmptyAllowed.NOEmailMessageTextAttachmentBuilder.attachTextFile(File, Charset, EmailMessageAttachmentTextNewLine, IsEmptyAllowed),
EmailMessageTextAttachmentBuilder.attachTextInputStream(InputStream, Charset, EmailMessageAttachmentTextNewLine, IsEmptyAllowed)Copyright © 2013–2020. All rights reserved.