/**
   * Create document for sent mail information
   *
   * @param processAttachmentsFolder
   * @param attachmentInfo
   */
  private void createDocumentForMail(Folder processAttachmentsFolder, String attachmentInfo) {
    String docName =
        RepositoryUtility.createDocumentName(
            processAttachmentsFolder,
            DocumentMgmtUtility.stripOffSpecialCharacters(mailSubject),
            0);

    DocumentInfo docInfo = DmsUtils.createDocumentInfo(docName);
    docInfo.setContentType(MimeTypesHelper.HTML.getType());
    docInfo.setOwner(ContextPortalServices.getUser().getAccount());

    // set correspondence data
    PrintDocumentAnnotations annotations = new PrintDocumentAnnotationsImpl();
    annotations.setTemplateType(DocumentTemplate.CORRESPONDENCE_TEMPLATE);
    annotations.setRecipients(getToMailAddress());
    annotations.setBlindCarbonCopyRecipients(bccMailAddress);
    annotations.setCarbonCopyRecipients(ccMailAddress);
    annotations.setFaxNumber(getFaxMailAddress());
    annotations.setSendDate(Calendar.getInstance().getTime());
    annotations.setAttachments(attachmentInfo);
    annotations.setSender(mailSender);
    annotations.setSubject(getMailSubject());
    annotations.setFaxEnabled(false);
    annotations.setEmailEnabled(false);

    docInfo.setDocumentAnnotations(annotations);

    Document mailDocument =
        DocumentMgmtUtility.getDocumentManagementService()
            .createDocument(
                processAttachmentsFolder.getId(), docInfo, editor.getContent().getBytes(), null);

    DMSHelper.addAndSaveProcessAttachment(processInstance, mailDocument);
  }
  /**
   * @param document
   * @return
   */
  private boolean isDocumentTemplate(Document document) {
    if (document.getContentType().trim().equals(MimeTypesHelper.HTML.getType())
        || document.getContentType().trim().equals(MimeTypesHelper.TXT.getType())) {
      return true;
    }

    return false;
  }