Uploaded image for project: 'Commons Email'
  1. Commons Email
  2. EMAIL-22

[email] New embed method for HtmlEmail

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • None
    • None
    • Operating System: other
      Platform: Other

    • 39391

    Description

      Hi!

      I've written a new "embed" method (simply but neccesary) for the HtmlEmail
      class:

      public String embed(DataSource ds, String name) throws EmailException{

      // verify that the DataSource is valid
      try
      {
      if (ds == null || ds.getInputStream() == null)

      { throw new EmailException("Invalid Datasource"); }

      }
      catch (IOException e)

      { throw new EmailException("Invalid Datasource"); }

      MimeBodyPart mbp = new MimeBodyPart();

      try

      { mbp.setDataHandler(new DataHandler(ds)); mbp.setFileName(name); mbp.setDisposition("inline"); String cid = randomAlphabetic(HtmlEmail.CID_LENGTH).toLowerCase(); mbp.addHeader("Content-ID", "<" + cid + ">"); this.inlineImages.add(mbp); return cid; }

      catch (MessagingException me)

      { throw new EmailException(me); }

      }

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ddiaz40@hotmail.com zarkon
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: