Package javax.mail

Examples of javax.mail.MessagingException


     else if (sContentClass.equals("java.lang.String")) {
       oRetVal = new MimeBodyPart();
       oRetVal.setText((String) oContent);
     }
     else {
       throw new MessagingException("Unparsed Mime Content " + oContent.getClass().getName());
     }

     if (null==oRetVal) {
       oRetVal = new MimeBodyPart();
       oRetVal.setText("");
View Full Code Here


      }
      catch (SQLException e) {
        if (null!=oConn) { try { oConn.rollback(); } catch (Exception ignore) {} }
        if (null!=oUpdt) { try { oUpdt.close(); } catch (Exception ignore) {} }
        if (DebugFile.trace) DebugFile.decIdent();
        throw new MessagingException(e.getMessage(), e);
      }
    }
  } // setFlag
View Full Code Here

        oConn=null;
      }
      catch (SQLException e) {
        if (null!=oConn) { try { oConn.rollback(); } catch (Exception ignore) {} }
        if (DebugFile.trace) DebugFile.decIdent();
        throw new MessagingException(e.getMessage(), e);
      }
    }
    else {
      super.saveChanges();
    }
View Full Code Here

        oStmt = null;

      } catch (SQLException sqle) {
        try { if (oRSet!=null) oRSet.close(); } catch (Exception e) {}
        try { if (oStmt!=null) oStmt.close(); } catch (Exception e) {}
        throw new MessagingException(sqle.getMessage(), sqle);
      }
      oRetVal = oMultiPart;
    }
    else {
      oRetVal = (MimeMultipart) super.getContent();
View Full Code Here

       oPipe.between(oInStrm, oBaStrm);
       oRetVal = new MimeBodyPart();
       oRetVal.setText(oBaStrm.toString("ISO8859_1"));
     }
     else {
       throw new MessagingException("Unparsed Mime Content " + oContent.getClass().getName());
     }

     if (null==oRetVal) {
       oRetVal = new MimeBodyPart();
       oRetVal.setText("");
View Full Code Here

        oStmt=null;
      }
      catch (SQLException sqle) {
        if (oRSet!=null) { try {oRSet.close();} catch (Exception ignore) {} }
        if (oStmt!=null) { try {oStmt.close();} catch (Exception ignore) {} }
        throw new MessagingException(sqle.getMessage(), sqle);
      }
      if (oBody!=null) {
        if (sType.startsWith("text/"))
          oBuffer.append(oBody.getContent());
        else
View Full Code Here

      Parser oPrsr = Parser.createParser(oHtmlBuff.toString(), getEncoding());
      StringBean oStrBn = new StringBean();
      try {
        oPrsr.visitAllNodesWith (oStrBn);
      } catch (ParserException pe) {
        throw new MessagingException(pe.getMessage(), pe);
      }
      // Code for HTML parser 1.4
      // oStrBn.setInputHTML(oHtmlBuff.toString());
      oBuffer.append(oStrBn.getStrings());
    }
    else {
      if (DebugFile.trace) DebugFile.writeln("Multipart = DBMimeMessage.getParts()");

      Multipart oParts = getParts();

      final int iParts = oParts.getCount();

      MimePart oPart;

      int p;
      for (p=0; p<iParts && !bHasPlainTextVersion; p++) {
        oPart = (MimePart) oParts.getBodyPart(p);

        String sType = oPart.getContentType();
        if (null!=sType) sType=sType.toLowerCase();
        String sDisp = oPart.getDisposition();
        if (null==sDisp) sDisp="inline"; else if (sDisp.length()==0) sDisp="inline";

        if (DebugFile.trace) DebugFile.writeln("scanning part " + String.valueOf(p) + sDisp + " " + sType.replace('\r',' ').replace('\n', ' '));

        if (sType.startsWith("text/plain") && sDisp.equalsIgnoreCase("inline")) {
          bHasPlainTextVersion = true;
          DBMimePart.parseMimePart (oBuffer, null,
                                    getFolder().getName(),
                                    getMessageID()!=null ? getMessageID() : getContentID(),
                                    oPart, p);
        }
      }

      if (DebugFile.trace) {
        if (bHasPlainTextVersion)
          DebugFile.writeln("MimeMultipart has plain text version at part " + String.valueOf(p));
        else
          DebugFile.writeln("MimeMultipart has no plain text version, converting part 0 from HTML");
      }

      if (!bHasPlainTextVersion) {
        oPart = (MimePart) oParts.getBodyPart(0);
        StringBuffer oHtml = new StringBuffer();
        DBMimePart.parseMimePart (oHtml, null, getFolder().getName(), getMessageID()!=null ? getMessageID() : getContentID(), oPart, 0);

        Parser oPrsr = Parser.createParser(oHtml.toString(), getEncoding());
        StringBean oStrBn = new StringBean();

        try {
          oPrsr.visitAllNodesWith (oStrBn);
        } catch (ParserException pe) {
          throw new MessagingException(pe.getMessage(), pe);
        }

        // Code for HTML parser 1.4
        // oSB.setInputHTML(oHtml.toString());
View Full Code Here

      DebugFile.incIdent();
    }

    if (getFolder()==null) {
      DebugFile.decIdent();
      throw new MessagingException("No folder for message");
    }

    DBFolder oDBF = (DBFolder) getFolder();

    if ((oDBF.getType()&DBFolder.MODE_MBOX)!=0) {
      try {
        if (oDBF.getConnection()==null) {
          if (DebugFile.trace) DebugFile.decIdent();
          throw new FolderClosedException(oDBF, "Folder is closed");
        }
      } catch (SQLException sqle) {
        throw new MessagingException(sqle.getMessage(), sqle);
      }

      PreparedStatement oStmt = null;
      ResultSet oRSet = null;
      BigDecimal oPos = null;
View Full Code Here

          oPrsr.visitAllNodesWith (oStrBn);
        } catch (ParserException pe) {
          if (DebugFile.trace) {
            DebugFile.writeln("org.htmlparser.util.ParserException " + pe.getMessage());
          }
          throw new MessagingException(pe.getMessage(), pe);
        }

        sText = oStrBn.getStrings();

        oStrBn = null;

        // *******************************
        // Set plain text alternative part

        oMsgPlainText.setDisposition("inline");
        oMsgPlainText.setText(sText,Charset.forName(sEncoding).name(),"plain");
        if (DebugFile.trace) DebugFile.writeln("MimeBodyPart(multipart/alternative).addBodyPart(text/plain)");
        oTextHtmlAlt.addBodyPart(oMsgPlainText);

        // *****************************************
        // Iterate images from HTML and replace CIDs

    if (bAttachInlineImages) {
      sBody = oHtmBdy.addPreffixToImgSrc("cid:");         
    } // fi (bAttachInlineImages)
      }
      catch (ParserException pe) {
        if (DebugFile.trace) {
          DebugFile.writeln("org.htmlparser.util.ParserException " + pe.getMessage());
        }
        throw new MessagingException(pe.getMessage(), pe);
      }
      // End replace image CIDs
      // ************************************************************************


      // ************************************************************************
      // Some defensive programming: ensure that all src="..." attributes point
      // either to an absolute http:// URL or to a cid:
      oHtmBdy.setHtml (sBody);
      ArrayList<String> aLocalUrls = oHtmBdy.extractLocalUrls();
      if (aLocalUrls.size()>0) {
        if (DebugFile.trace) {
          DebugFile.writeln("HTML body part contains local references to external resources");
          for (String i : aLocalUrls) {
            DebugFile.writeln(i);
          }
          DebugFile.write(sBody+"\n");
        }
        throw new MessagingException("HTML body part "+(sId==null ? "" : "of message"+sId)+" contains local references to external resources such as "+aLocalUrls.get(0));
      } // aLocalUrls != {}

     
      // ************************************************************************
      // Add HTML related images
View Full Code Here

      throw new StoreClosedException(getStore(), "Store is not connected");

    try {
      return oCatg.exists(getConnection());
    } catch (SQLException sqle) {
      throw new MessagingException(sqle.getMessage(), sqle);
    }
  }
View Full Code Here

TOP

Related Classes of javax.mail.MessagingException

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.