Package org.openntf.domino

Examples of org.openntf.domino.MIMEEntity


    checkMimeOpen();
    try {
      byte[] ret = getDelegate().getItemValueCustomDataBytes(itemName, dataTypeName);
      if (ret != null && ret.length != 0)
        return ret;
      MIMEEntity entity;
      if ((entity = getMIMEEntity(itemName)) == null)
        return ret;
      Object o = null;
      try {
        o = Documents.getItemValueMIME(this, itemName, entity);
View Full Code Here


    } catch (NotesException e) {
      DominoUtils.handleException(e, this);
    }

    if (itemType == Type.MIME_PART) {
      MIMEEntity entity = getMIMEEntity();
      if (entity != null) {
        MIMEHeader contentType = entity.getNthHeader("Content-Type");
        String headerval = contentType.getHeaderVal();
        if ("application/x-java-serialized-object".equals(headerval) || "application/x-java-externalized-object".equals(headerval)) {
          itemType = Type.MIME_BEAN;
        }
        getParent().closeMIMEEntities(false, getName());
View Full Code Here

          } else {
            is = new ByteArrayInputStream(attach.getBytes());
          }

          if (null != is) {
            MIMEEntity mimeChild = parent.createChildEntity();
            MIMEHeader mimeHeader = mimeChild.createHeader("Content-Disposition");

            if (attach.isInlineImage()) {
              mimeHeader.setHeaderVal("inline; filename=\"" + attach.getFileName() + "\"");
            } else {
              mimeHeader.setHeaderVal("attachment; filename=\"" + attach.getFileName() + "\"");
            }

            mimeHeader = mimeChild.createHeader("Content-ID");
            mimeHeader.setHeaderVal("<" + attach.getContentId() + ">");

            streamFile = getSession().createStream();
            streamFile.setContents(is);
            mimeChild.setContentFromBytes(streamFile, contentType, MIMEEntity.ENC_IDENTITY_BINARY);
            streamFile.close();
          }
        } catch (Exception e) {
          DominoUtils.handleException(e);
        } finally {
View Full Code Here

   */
  @Override
  public Document send() {
    try {
      Stream stream;
      MIMEEntity mimeEntity;
      MIMEHeader mimeHeader;
      Database currDb;

      Session currSess = getSession();
      currSess.setConvertMime(false); // in case Khan is still in suspended animation!

      // Create memo doc
      try {
        currDb = currSess.getCurrentDatabase();
        if (null == currDb) {
          // Will this work if we're running from DOTS or OSGi plugin??
          currDb = currSess.getDatabase(currSess.getServerName(), "mail.box");
        }
      } catch (Throwable t) {
        currDb = currSess.getDatabase(currSess.getServerName(), "mail.box");
      }
      Document memo = currDb.createDocument();
      memo.put("RecNoOutOfOffice", "1");    //no replies from out of office agents
      MIMEEntity mimeRoot = memo.createMIMEEntity("Body");

      mimeHeader = mimeRoot.createHeader("To");
      mimeHeader.setHeaderVal(join(getTo(), ""));
      memo.replaceItemValue("sendTo", getTo());

      if (cc_.size() > 0) {
        mimeHeader = mimeRoot.createHeader("CC");
        mimeHeader.setHeaderVal(join(getCC(), ""));
        memo.replaceItemValue("cc", getCC());
      }

      if (bcc_.size() > 0) {
        mimeHeader = mimeRoot.createHeader("BCC");
        mimeHeader.setHeaderVal(join(getBCC(), ""));
        memo.replaceItemValue("bcc", getBCC());
      }

      //set subject
      mimeHeader = mimeRoot.createHeader("Subject");
      mimeHeader.setHeaderVal(getSubject());

      //create text/alternative directive: text/plain and text/html part will be childs of this entity
      MIMEEntity mimeRootChild = mimeRoot.createChildEntity();
      String mimeBoundary = memo.getUniversalID().toLowerCase();
      mimeHeader = mimeRootChild.createHeader("Content-Type");
      mimeHeader.setHeaderVal("multipart/alternative; boundary=\"" + mimeBoundary + "\"");

      //create plain text part
      if (getText().size() > 0) {
        mimeEntity = mimeRootChild.createChildEntity();
        stream = currSess.createStream();
        stream.writeText(join(getText(), System.getProperty("line.separator")));
        mimeEntity.setContentFromText(stream, "text/plain; charset=\"UTF-8\"", MIMEEntity.ENC_NONE);
        stream.close();
      }

      //create HTML part
      if (contentsHTML_.size() > 0) {
        mimeEntity = mimeRootChild.createChildEntity();
        stream = currSess.createStream();
        stream.writeText(join(contentsHTML_, System.getProperty("line.separator")));
        mimeEntity.setContentFromText(stream, "text/html; charset=\"UTF-8\"", MIMEEntity.ENC_NONE);
        stream.close();
      }

      //create embedded JSON part
      if (StringUtil.isEmpty(getJSON())) {
        mimeEntity = mimeRootChild.createChildEntity();
        stream = currSess.createStream();
        String json = "{\"url\" : \"" + getJSON() + "\"}" + System.getProperty("line.separator");
        stream.writeText(json);
        mimeEntity.setContentFromText(stream, "application/embed+json; charset=\"UTF-8\"", MIMEEntity.ENC_NONE);
        stream.close();
View Full Code Here

TOP

Related Classes of org.openntf.domino.MIMEEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.