/** * Set the priority ("X-Priority" header) of the message. * @param priority the priority value; * typically between 1 (highest) and 5 (lowest) * @throws MessagingException in case of errors */ public void setPriority(int priority) throws MessagingException { this.mimeMessage.setHeader(HEADER_PRIORITY, Integer.toString(priority)); }
/** * Set the priority ("X-Priority" header) of the message. * @param priority the priority value; * typically between 1 (highest) and 5 (lowest) * @throws MessagingException in case of errors */ public void setPriority(int priority) throws MessagingException { this.mimeMessage.setHeader(HEADER_PRIORITY, Integer.toString(priority)); }
MimeMessage msg = new MimeMessage(session); msg.setHeader("Content-Type", encodingOptions); msg.setFrom(new javax.mail.internet.InternetAddress(emailFrom)); msg.addRecipient(Message.RecipientType.TO, new InternetAddress(emailTo)); msg.setSubject(subject, "UTF-8");
/** * Sets headers in msgToSet with headers from emailWithData. * * @param emailWithData {@link Email} with data * @param msgToSet {@link MimeMessage} to set data into. * @throws MessagingException if there is a failure */ private void setHeaders(final Email emailWithData, final MimeMessage msgToSet) throws MessagingException { final Map<String, String> headers = emailWithData.headers(); if (headers != null) { for (final Map.Entry<String, String> entry : headers.entrySet()) { msgToSet.setHeader(entry.getKey(), entry.getValue()); } } }
if (messageId != null) { mimeMessage.setHeader(HEADER_MESSAGE_ID, messageId);
if (messageId != null) { mimeMessage.setHeader(HEADER_MESSAGE_ID, messageId);
/** * Set the "Content-MD5" header field of this Message. * * @exception IllegalWriteException if the underlying * implementation does not support modification * @exception IllegalStateException if this message is * obtained from a READ_ONLY folder. * @exception MessagingException for other failures */ public void setContentMD5(String md5) throws MessagingException { setHeader("Content-MD5", md5); }
/** * Set the "Content-MD5" header field of this Message. * * @exception IllegalWriteException if the underlying * implementation does not support modification * @exception IllegalStateException if this message is * obtained from a READ_ONLY folder. * @exception MessagingException for other failures */ @Override public void setContentMD5(String md5) throws MessagingException { setHeader("Content-MD5", md5); }
/** * Update the Message-ID header. This method is called * by the <code>updateHeaders</code> and allows a subclass * to override only the algorithm for choosing a Message-ID. * * @exception MessagingException for failures * @since JavaMail 1.4 */ protected void updateMessageID() throws MessagingException { setHeader("Message-ID", "<" + UniqueValue.getUniqueMessageIDValue(session) + ">"); }
/** * Update the Message-ID header. This method is called * by the <code>updateHeaders</code> and allows a subclass * to override only the algorithm for choosing a Message-ID. * * @exception MessagingException for failures * @since JavaMail 1.4 */ protected void updateMessageID() throws MessagingException { setHeader("Message-ID", "<" + UniqueValue.getUniqueMessageIDValue(session) + ">"); }
/** * Set the "Content-ID" header field of this Message. * If the <code>cid</code> parameter is null, any existing * "Content-ID" is removed. * * @param cid the content ID * @exception IllegalWriteException if the underlying * implementation does not support modification * @exception IllegalStateException if this message is * obtained from a READ_ONLY folder. * @exception MessagingException for other failures */ public void setContentID(String cid) throws MessagingException { if (cid == null) removeHeader("Content-ID"); else setHeader("Content-ID", cid); }
/** * Set the "Content-ID" header field of this Message. * If the <code>cid</code> parameter is null, any existing * "Content-ID" is removed. * * @param cid the content ID * @exception IllegalWriteException if the underlying * implementation does not support modification * @exception IllegalStateException if this message is * obtained from a READ_ONLY folder. * @exception MessagingException for other failures */ public void setContentID(String cid) throws MessagingException { if (cid == null) removeHeader("Content-ID"); else setHeader("Content-ID", cid); }
private void setAddressHeader(String name, Address[] addresses) throws MessagingException { String s = InternetAddress.toString(addresses, name.length() + 2); if (s == null) removeHeader(name); else setHeader(name, s); }
private void addAddressHeader(String name, Address[] addresses) throws MessagingException { if (addresses == null || addresses.length == 0) return; Address[] a = getAddressHeader(name); Address[] anew; if (a == null || a.length == 0) anew = addresses; else { anew = new Address[a.length + addresses.length]; System.arraycopy(a, 0, anew, 0, a.length); System.arraycopy(addresses, 0, anew, a.length, addresses.length); } String s = InternetAddress.toString(anew, name.length() + 2); if (s == null) return; setHeader(name, s); }
private void setAddressHeader(String name, Address[] addresses) throws MessagingException { String s; if (allowutf8) s = InternetAddress.toUnicodeString(addresses, name.length() + 2); else s = InternetAddress.toString(addresses, name.length() + 2); if (s == null) removeHeader(name); else setHeader(name, s); }
/** * Set the RFC 822 "From" header field. Any existing values are * replaced with the given address. If address is <code>null</code>, * this header is removed. * * @param address the sender of this message * @exception IllegalWriteException if the underlying * implementation does not support modification * of existing values * @exception IllegalStateException if this message is * obtained from a READ_ONLY folder. * @exception MessagingException for other failures */ public void setFrom(Address address) throws MessagingException { if (address == null) removeHeader("From"); else setHeader("From", MimeUtility.fold(6, address.toString())); }
/** * Set the RFC 822 "Sender" header field. Any existing values are * replaced with the given address. If address is <code>null</code>, * this header is removed. * * @param address the sender of this message * @exception IllegalWriteException if the underlying * implementation does not support modification * of existing values * @exception IllegalStateException if this message is * obtained from a READ_ONLY folder. * @exception MessagingException for other failures * @since JavaMail 1.3 */ public void setSender(Address address) throws MessagingException { if (address == null) removeHeader("Sender"); else setHeader("Sender", MimeUtility.fold(8, address.toString())); }
/** * Set the RFC 822 "From" header field. Any existing values are * replaced with the given address. If address is <code>null</code>, * this header is removed. * * @param address the sender of this message * @exception IllegalWriteException if the underlying * implementation does not support modification * of existing values * @exception IllegalStateException if this message is * obtained from a READ_ONLY folder. * @exception MessagingException for other failures */ @Override public void setFrom(Address address) throws MessagingException { if (address == null) removeHeader("From"); else setHeader("From", MimeUtility.fold(6, address.toString())); }
/** * Set the RFC 822 "Sender" header field. Any existing values are * replaced with the given address. If address is <code>null</code>, * this header is removed. * * @param address the sender of this message * @exception IllegalWriteException if the underlying * implementation does not support modification * of existing values * @exception IllegalStateException if this message is * obtained from a READ_ONLY folder. * @exception MessagingException for other failures * @since JavaMail 1.3 */ public void setSender(Address address) throws MessagingException { if (address == null) removeHeader("Sender"); else setHeader("Sender", MimeUtility.fold(8, address.toString())); }