Class Messages
java.lang.Object
ch.tocco.nice2.messaging.mail.spi.Messages
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
closeFolder
(jakarta.mail.Message message, boolean expunge) static void
ensureFolderOpen
(jakarta.mail.Message message, int mode) Opens the folder of the given message if it's not already open.getAllHeaders
(jakarta.mail.Message message) Transforms all headers of the message into a map.static @Nullable String
getFirstEmailAddress
(@Nullable jakarta.mail.Address[] addresses) static jakarta.mail.internet.InternetAddress
getFrom
(jakarta.mail.Message message) Returns the singleInternetAddress
in the from header.getHeaders
(Enumeration headers) Transforms the given enumeration ofheader objects
into a map.static Iterable
<jakarta.mail.internet.InternetAddress> getRecipients
(jakarta.mail.Message message, jakarta.mail.Message.RecipientType type) Returns an iterable over the recipients addresses of the given type.static Iterable
<jakarta.mail.internet.InternetAddress> getReplyTos
(jakarta.mail.Message message) static @Nullable String
joinEmailAddresses
(@Nullable jakarta.mail.Address[] addresses, String split) static @Nullable String
joinEmailAddresses
(@Nullable Iterable<jakarta.mail.internet.InternetAddress> addresses, String split) parseHeaderLines
(List<String> headerLines) Transforms the given string list into a map header map.Returns a function that convertsInternetAddress
es to strings, while returning only the address part.static Function
<jakarta.mail.Address, jakarta.mail.internet.InternetAddress> static @Nullable Iterable
<jakarta.mail.internet.InternetAddress> toInternetAddresses
(@Nullable jakarta.mail.Address[] addresses) Filters the specified iterable ofAddress
es and returns a iterable that contains all elements from the argument that are of typeInternetAddress
.static @Nullable Iterable
<jakarta.mail.internet.InternetAddress> toInternetAddresses
(@Nullable Iterable<jakarta.mail.Address> addresses) Filters the specified iterable ofAddress
es and returns a iterable that contains all elements from the argument that are of typeInternetAddress
.
-
Field Details
-
NO_SENDER_ADDRESS_PLACEHOLDER
- See Also:
-
-
Method Details
-
toEmailAddress
Returns a function that convertsInternetAddress
es to strings, while returning only the address part. Groups are resolved to a comma separated list of addresses. Returnsnull
, if input isnull
. The function may throw anIllegalArgumentException
if group parsing fails. -
toNameAndEmailAddress
-
toInternetAddresses
@Nullable public static @Nullable Iterable<jakarta.mail.internet.InternetAddress> toInternetAddresses(@Nullable @Nullable Iterable<jakarta.mail.Address> addresses) Filters the specified iterable ofAddress
es and returns a iterable that contains all elements from the argument that are of typeInternetAddress
. -
toInternetAddresses
@Nullable public static @Nullable Iterable<jakarta.mail.internet.InternetAddress> toInternetAddresses(@Nullable @Nullable jakarta.mail.Address[] addresses) Filters the specified iterable ofAddress
es and returns a iterable that contains all elements from the argument that are of typeInternetAddress
. -
getFirstEmailAddress
@Nullable public static @Nullable String getFirstEmailAddress(@Nullable @Nullable jakarta.mail.Address[] addresses) -
joinEmailAddresses
-
joinEmailAddresses
-
getFrom
public static jakarta.mail.internet.InternetAddress getFrom(jakarta.mail.Message message) throws jakarta.mail.MessagingException Returns the singleInternetAddress
in the from header.- Throws:
jakarta.mail.MessagingException
-
getRecipients
public static Iterable<jakarta.mail.internet.InternetAddress> getRecipients(jakarta.mail.Message message, @Nullable jakarta.mail.Message.RecipientType type) Returns an iterable over the recipients addresses of the given type. Iftype
isnull
all recipients
are returned. -
getReplyTos
public static Iterable<jakarta.mail.internet.InternetAddress> getReplyTos(jakarta.mail.Message message) -
getAllHeaders
public static Map<String,Iterable<String>> getAllHeaders(jakarta.mail.Message message) throws jakarta.mail.MessagingException Transforms all headers of the message into a map. Empty header lines will be skipped such that the mapped iterable only contains not-null and non-empty strings.- Throws:
jakarta.mail.MessagingException
-
getHeaders
Transforms the given enumeration ofheader objects
into a map. Empty header lines will be skipped such that the mapped iterable only contains not-null and non-empty strings. -
parseHeaderLines
Transforms the given string list into a map header map. Splits the line at the first colon followed by a space. The part before the first ": " is used as key, the rest as value. If a line does not contain ": " it is ignored. -
ensureFolderOpen
public static void ensureFolderOpen(jakarta.mail.Message message, int mode) throws jakarta.mail.MessagingException Opens the folder of the given message if it's not already open. If the message has no folder (message.getFolder() == null
), this method does nothing.- Parameters:
mode
- the open mode, one ofFolder.READ_ONLY
,Folder.READ_WRITE
- Throws:
IllegalArgumentException
- if message has no folderjakarta.mail.MessagingException
-
closeFolder
public static void closeFolder(jakarta.mail.Message message, boolean expunge) -
toInternetAddress
public static Function<jakarta.mail.Address,jakarta.mail.internet.InternetAddress> toInternetAddress()
-