Package de.businesscode.util
Class SendEmail
java.lang.Object
de.businesscode.util.SendEmail
Set these jndi properties.
de.businesscode.bcdui.localjndi.smtp.host = mysmtphost
de.businesscode.bcdui.localjndi.smtp.password = mysmtppassword
de.businesscode.bcdui.localjndi.smtp.sender = NOREPLY@myemail.com
de.businesscode.bcdui.localjndi.smtp.user = mysmtpuser
de.businesscode.bcdui.localjndi.smtp.port = 25
de.businesscode.bcdui.localjndi.smtp.starttls = true|false
de.businesscode.bcdui.localjndi.smtp.subject = Scheduled Report
de.businesscode.bcdui.localjndi.smtp.body = Please find your report attached.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
protected jakarta.mail.internet.InternetAddress
protected String
static String
static String
static String
static String
static String
static String
static String
static String
protected jakarta.mail.internet.MimeMessage
protected String
protected int
protected jakarta.mail.Session
protected boolean
protected String
protected String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Create a Session object to represent a mail session with the specified properties.void
Actually send an email to multiple receipientsvoid
send
(String receipients, String subject, String body, String attachmentName, File attachment, boolean html) Actually send an email to multiple receipientsvoid
send
(String receipients, String subject, String body, Map<String, jakarta.activation.DataSource> attachments, boolean html) Actually send an email to multiple receipientsvoid
sendCC
(String receipients, String receipientsCc, String receipientsBcc, String subject, String body, Map<String, jakarta.activation.DataSource> attachments, boolean html) Actually send an email to multiple receipientsvoid
sendWithFilenames
(String receipients, String subject, String body, Map<String, String> attachmentFilenames, boolean html) Actually send an email to multiple receipientsvoid
sendWithFiles
(String receipients, String subject, String body, Map<String, File> attachmentFiles, boolean html) Actually send an email to multiple receipientsvoid
-
Field Details
-
JNDI_SMTP_HOST
-
JNDI_SMTP_PORT
-
JNDI_SMTP_STARTTLS
-
JNDI_SMTP_USER
-
JNDI_SMTP_PASSWORD
-
JNDI_SMTP_SENDER
-
JNDI_SMTP_BODY
-
JNDI_SMTP_SUBJECT
-
session
protected jakarta.mail.Session session -
host
-
port
protected int port -
starttls
protected boolean starttls -
user
-
password
-
subject
-
body
-
fromInternetAddress
protected jakarta.mail.internet.InternetAddress fromInternetAddress -
nextMessage
protected jakarta.mail.internet.MimeMessage nextMessage
-
-
Constructor Details
-
SendEmail
public SendEmail(String host, Integer port, boolean starttls, String sender, String user, String password) throws jakarta.mail.internet.AddressException, GeneralSecurityException Create once, use send() multiple times- Parameters:
host
-port
-sender
-user
-password
-- Throws:
jakarta.mail.internet.AddressException
GeneralSecurityException
-
SendEmail
public SendEmail() throws jakarta.mail.internet.AddressException, NamingException, GeneralSecurityExceptionReads email account settings from JNDI context- Parameters:
host
-port
-sender
-user
-password
-- Throws:
jakarta.mail.internet.AddressException
NamingException
GeneralSecurityException
-
-
Method Details
-
setSender
- Throws:
jakarta.mail.internet.AddressException
-
initSession
Create a Session object to represent a mail session with the specified properties. Sessions do not need to be closed- Parameters:
port
-- Throws:
GeneralSecurityException
-
send
public void send(String receipients, String subject, String body, boolean html) throws jakarta.mail.MessagingException Actually send an email to multiple receipients- Parameters:
receipients
- semicolon separatedsubject
-body
-attachments
- may be null- Throws:
jakarta.mail.MessagingException
-
send
public void send(String receipients, String subject, String body, String attachmentName, File attachment, boolean html) throws jakarta.mail.MessagingException Actually send an email to multiple receipients- Parameters:
receipients
- semicolon separatedsubject
-body
-attachments
- may be null- Throws:
jakarta.mail.MessagingException
-
sendWithFilenames
public void sendWithFilenames(String receipients, String subject, String body, Map<String, String> attachmentFilenames, boolean html) throws jakarta.mail.MessagingExceptionActually send an email to multiple receipients- Parameters:
receipients
-subject
-body
-attachments
- attachmentname - filename- Throws:
jakarta.mail.MessagingException
-
sendWithFiles
public void sendWithFiles(String receipients, String subject, String body, Map<String, File> attachmentFiles, boolean html) throws jakarta.mail.MessagingExceptionActually send an email to multiple receipients- Parameters:
receipients
- semicolon separatedsubject
-body
-attachments
- attachmentname - file- Throws:
jakarta.mail.MessagingException
-
send
public void send(String receipients, String subject, String body, Map<String, jakarta.activation.DataSource> attachments, boolean html) throws jakarta.mail.MessagingExceptionActually send an email to multiple receipients- Parameters:
receipients
- semicolon separatedsubject
-body
-attachments
-- Throws:
jakarta.mail.MessagingException
-
sendCC
public void sendCC(String receipients, String receipientsCc, String receipientsBcc, String subject, String body, Map<String, jakarta.activation.DataSource> attachments, boolean html) throws jakarta.mail.MessagingExceptionActually send an email to multiple receipients- Parameters:
receipients
- semicolon separatedcc
- receipients semicolon separatedsubject
-body
-attachments
-- Throws:
jakarta.mail.MessagingException
-