public interface EmailMessageTextAttachmentBuilder
JavaMailSessionBuilderFactory.INSTANCE| 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.
|
EmailMessageBuilder parent()
EmailMessageTextAttachmentBuilder attachmentFileName(String attachmentFileName)
Sets the attachment type to EmailMessageAttachmentType.ATTACHMENT and sets the attachment file name.
attachmentFileName - only a file name -- does not include a parent path
"log.txt"inline()EmailMessageTextAttachmentBuilder inline()
EmailMessageAttachmentType.INLINE and clears the attachment file name.attachmentFileName(String)EmailMessageTextAttachmentBuilder textMimeSubType(TextMimeSubType textMimeSubType)
For custom types, see: customTextMimeSubType(String).
customTextMimeSubType(String)EmailMessageTextAttachmentBuilder customTextMimeSubType(String customTextMimeSubType)
For common types, see textMimeSubType(TextMimeSubType).
textMimeSubType(TextMimeSubType)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!
filePath - 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
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 emptyattachTextInputStream(InputStream, Charset, EmailMessageAttachmentTextNewLine, IsEmptyAllowed),
attachText(String, EmailMessageAttachmentTextNewLine, IsEmptyAllowed)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!
inputStream - 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
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 emptyattachTextFile(File, Charset, EmailMessageAttachmentTextNewLine, IsEmptyAllowed),
attachText(String, EmailMessageAttachmentTextNewLine, IsEmptyAllowed)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!
text - text for attachmentnewLine - for internal emails at large corporations, EmailMessageAttachmentTextNewLine.WINDOWS is probably
most friendly towards Microsoft Windows and Microsoft Outlook users
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.NOIllegalArgumentException - if isEmptyAllowed is IsEmptyAllowed.NO and text is emptyattachTextFile(File, Charset, EmailMessageAttachmentTextNewLine, IsEmptyAllowed),
attachTextInputStream(InputStream, Charset, EmailMessageAttachmentTextNewLine, IsEmptyAllowed)Copyright © 2013–2020. All rights reserved.