程序包 com.sh.mail.core

类 HtmlEmail


public class HtmlEmail extends MultiPartEmail

Description: An HTML multipart email.

Title:首亨软件 - TSS/CRM等

从以下版本开始:
Aug 13, 2012
  • 字段详细资料

    • CID_LENGTH

      public static final int CID_LENGTH
      Definition of the length of generated CID's
      另请参阅:
    • text

      protected String text
      Text part of the message. This will be used as alternative text if the email client does not support HTML messages.
    • html

      protected String html
      Html part of the message
    • inlineImages

      protected List inlineImages
      As of commons-email 1.1, no longer used. Inline embedded objects are now stored in inlineEmbeds.
    • inlineEmbeds

      protected Map inlineEmbeds
      Embedded images Map<String, InlineImage> where the key is the user-defined image name.
  • 构造器详细资料

    • HtmlEmail

      public HtmlEmail()
  • 方法详细资料

    • setTextMsg

      public HtmlEmail setTextMsg(String aText) throws EmailException
      Set the text content.
      参数:
      aText - A String.
      返回:
      An HtmlEmail.
      抛出:
      EmailException - see javax.mail.internet.MimeBodyPart for definitions
      从以下版本开始:
      1.0
    • setHtmlMsg

      public HtmlEmail setHtmlMsg(String aHtml) throws EmailException
      Set the HTML content.
      参数:
      aHtml - A String.
      返回:
      An HtmlEmail.
      抛出:
      EmailException - see javax.mail.internet.MimeBodyPart for definitions
      从以下版本开始:
      1.0
    • setMsg

      public Email setMsg(String msg) throws EmailException
      Set the message.

      This method overrides MultiPartEmail.setMsg(String) in order to send an HTML message instead of a plain text message in the mail body. The message is formatted in HTML for the HTML part of the message; it is left as is in the alternate text part.

      覆盖:
      setMsg 在类中 MultiPartEmail
      参数:
      msg - the message text to use
      返回:
      this HtmlEmail
      抛出:
      EmailException - if msg is null or empty; see javax.mail.internet.MimeBodyPart for definitions
      从以下版本开始:
      1.0
    • embed

      public String embed(String urlString, String name) throws EmailException
      Attempts to parse the specified String as a URL that will then be embedded in the message.
      参数:
      urlString - String representation of the URL.
      name - The name that will be set in the filename header field.
      返回:
      A String with the Content-ID of the URL.
      抛出:
      EmailException - when URL supplied is invalid or if is null or empty; also see javax.mail.internet.MimeBodyPart for definitions
      从以下版本开始:
      1.1
      另请参阅:
    • embed

      public String embed(URL url, String name) throws EmailException
      Embeds an URL in the HTML.

      This method embeds a file located by an URL into the mail body. It allows, for instance, to add inline images to the email. Inline files may be referenced with a cid:xxxxxx URL, where xxxxxx is the Content-ID returned by the embed function. It is an error to bind the same name to more than one URL; if the same URL is embedded multiple times, the same Content-ID is guaranteed to be returned.

      While functionally the same as passing URLDataSource to embed(DataSource, String, String), this method attempts to validate the URL before embedding it in the message and will throw EmailException if the validation fails. In this case, the HtmlEmail object will not be changed.

      NOTE: Clients should take care to ensure that different URLs are bound to different names. This implementation tries to detect this and throw EmailException. However, it is not guaranteed to catch all cases, especially when the URL refers to a remote HTTP host that may be part of a virtual host cluster.

      参数:
      url - The URL of the file.
      name - The name that will be set in the filename header field.
      返回:
      A String with the Content-ID of the file.
      抛出:
      EmailException - when URL supplied is invalid or if is null or empty; also see javax.mail.internet.MimeBodyPart for definitions
      从以下版本开始:
      1.0
    • embed

      public String embed(File file) throws EmailException
      Embeds a file in the HTML. This implementation delegates to embed(File, String).
      参数:
      file - The File object to embed
      返回:
      A String with the Content-ID of the file.
      抛出:
      EmailException - when the supplied File cannot be used; also see javax.mail.internet.MimeBodyPart for definitions
      从以下版本开始:
      1.1
      另请参阅:
    • embed

      public String embed(File file, String cid) throws EmailException
      Embeds a file in the HTML.

      This method embeds a file located by an URL into the mail body. It allows, for instance, to add inline images to the email. Inline files may be referenced with a cid:xxxxxx URL, where xxxxxx is the Content-ID returned by the embed function. Files are bound to their names, which is the value returned by File.getName(). If the same file is embedded multiple times, the same CID is guaranteed to be returned.

      While functionally the same as passing FileDataSource to embed(DataSource, String, String), this method attempts to validate the file before embedding it in the message and will throw EmailException if the validation fails. In this case, the HtmlEmail object will not be changed.

      参数:
      file - The File to embed
      cid - the Content-ID to use for the embedded File
      返回:
      A String with the Content-ID of the file.
      抛出:
      EmailException - when the supplied File cannot be used or if the file has already been embedded; also see javax.mail.internet.MimeBodyPart for definitions
      从以下版本开始:
      1.1
    • embed

      public String embed(jakarta.activation.DataSource dataSource, String name) throws EmailException
      Embeds the specified DataSource in the HTML using a randomly generated Content-ID. Returns the generated Content-ID string.
      参数:
      dataSource - the DataSource to embed
      name - the name that will be set in the filename header field
      返回:
      the generated Content-ID for this DataSource
      抛出:
      EmailException - if the embedding fails or if name is null or empty
      从以下版本开始:
      1.1
      另请参阅:
    • embed

      public String embed(jakarta.activation.DataSource dataSource, String name, String cid) throws EmailException
      Embeds the specified DataSource in the HTML using the specified Content-ID. Returns the specified Content-ID string.
      参数:
      dataSource - the DataSource to embed
      name - the name that will be set in the filename header field
      cid - the Content-ID to use for this DataSource
      返回:
      the supplied Content-ID for this DataSource
      抛出:
      EmailException - if the embedding fails or if name is null or empty
      从以下版本开始:
      1.1
    • buildMimeMessage

      public void buildMimeMessage() throws EmailException
      Does the work of actually building the email.
      覆盖:
      buildMimeMessage 在类中 MultiPartEmail
      抛出:
      EmailException - if there was an error.
      从以下版本开始:
      1.0