public class EmailAttachment extends Object
| Modifier and Type | Field and Description |
|---|---|
static Pattern |
INLINE_ATTACHMENT_PLACEHOLDER_RE
Regex that helps to locate places in the text of email message body with inline files.
|
static Pattern |
INLINE_IMAGE_PLACEHOLDER_RE
Regex that helps to locate places in the text of email message body with inline images.
|
| Constructor and Description |
|---|
EmailAttachment(Path path)
Constructs a mew EmailAttachment with given file.
|
EmailAttachment(String fileName,
byte[] content,
String mimeType)
Constructs a mew EmailAttachment with provided file data.
|
EmailAttachment(String fileName,
InputStream contentSource,
String mimeType)
Constructs a mew EmailAttachment with provided file data.
|
| Modifier and Type | Method and Description |
|---|---|
static String |
getAttachmentPlaceholder(String fileName)
Generates the string that indicates a place in the text of email message body where the attached file with
given name should be inserted.
|
byte[] |
getContent()
Gets the file content of this attachment.
|
String |
getFileName()
Gets the file name of this attachment.
|
static String |
getImagePlaceholder(String fileName,
int width,
int height)
Generates the string that indicates a place in the text of email message body where the attached image with
given name and specific size should be inserted.
|
InputStream |
getInputStream()
Gets the file content of this attachment as stream.
|
String |
getMimeType()
Gets MIME type of this attachment.
|
String |
toString() |
public static final Pattern INLINE_IMAGE_PLACEHOLDER_RE
public static final Pattern INLINE_ATTACHMENT_PLACEHOLDER_RE
public EmailAttachment(String fileName, InputStream contentSource, String mimeType)
fileName - the name of file.contentSource - the InputStream that provides file content.mimeType - the MIME type of file.public EmailAttachment(Path path) throws IOException
path - the Path to file.IOException - in case of some errors during reading of file.public static String getImagePlaceholder(String fileName, int width, int height)
fileName - the name of attached to the email message image that should be inline in the text of this
message body.width - the necessary width of the image in pixels.height - the necessary height of the image in pixels.public static String getAttachmentPlaceholder(String fileName)
fileName - the name of attached to the email message file that should be inline in the text of this
message body.public String getFileName()
public InputStream getInputStream()
ByteArrayInputStream with file content of this attachment.public byte[] getContent()
public String getMimeType()
Copyright © 2023. All rights reserved.