Package javax.mail

Examples of javax.mail.MessagingException


     * @throws MessagingException
     * @throws SendFailedException
     */
    public void sendMail() throws MessagingException, SendFailedException {
        if (mailToAddress == null)
            throw new MessagingException("The recipient is required.");
        mailMessage.setContent(multipart);
        Transport.send(mailMessage);
    }
View Full Code Here


        Transport.send(mailMessage);
    }
   
    public MimeMessage getMimeMessage() throws MessagingException{
        if (mailToAddress == null)
            throw new MessagingException("The recipient is required.");
        mailMessage.setContent(multipart);
        return mailMessage;
    }
View Full Code Here

            message.addRecipient(parseType(type), new InternetAddress(address, name, "UTF-8"));
          }
          catch (UnsupportedEncodingException e)
          {
            // Should not happen - UTF-8 is safe to use
            throw new MessagingException("Failed to encode recipient", e);
          }
        }
      }
    }
  }
View Full Code Here

   */
  public static void sendMail(String host, String from, String to, String cc,
        String subject, String body, Vector attachments) throws MessagingException
  {
    if (from == null || from.length() == 0) {
      throw new MessagingException("No 'From' address specified");
    }
    if (to == null || to.length() == 0) {
      throw new MessagingException("No 'To' address specified");
    }

    Properties properties = System.getProperties();
    properties.put("mail.smtp.host", host);
    javax.mail.Session session = Session.getDefaultInstance(properties,null);
View Full Code Here

          StringBean oStrBn = new StringBean();

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

          sTextBody = oStrBn.getStrings();

          oStrBn = null;
View Full Code Here

    { // HP Java runtime did not recognise MessagingException as a subtype
      // of
      // Throwable.
      try
      {
        MessagingException me = (MessagingException) e;
        Exception nextException = me.getNextException();
        if (nextException != null)
        {
          Trace.error(nextException.getMessage());
          if (nextException instanceof SendFailedException)
          {
View Full Code Here

    else if (sRecipientType.equalsIgnoreCase("bcc"))
      oRecType = RecipientType.BCC;
    else if (sRecipientType.equalsIgnoreCase("to"))
    oRecType = RecipientType.TO;
    else
      throw new MessagingException(sRecipientType+" is not a valid recipient type");

    if (sJobTl.length()>0) {
    if (null==oGlobalDbb)
      oDbb = new DBBind(sEnvCnfFileName);
    else
View Full Code Here

          if (!oRSet.wasNull()) iLen = Integer.parseInt(oLenPart.toString()); else iLen = -1;
          oOffset = oRSet.getObject(6);
          if (!oRSet.wasNull()) lOff = Long.parseLong(oOffset.toString()); else lOff = -1;

          if (lPos!=-1) {
            if (iLen==-1) throw new MessagingException("Part " + String.valueOf(iPartId) + " length not set at k_mime_parts table for message "+getMessage().getMessageGuid());
            if (lOff==-1 ) throw new MessagingException("Part " + String.valueOf(iPartId) + " offset not set at k_mime_parts table for message "+getMessage().getMessageGuid());

            if (DebugFile.trace) DebugFile.writeln("new MboxFile("+((DBFolder)getMessage().getFolder()).getFile()+")");

            MboxFile oMbox = new MboxFile(((DBFolder)getMessage().getFolder()).getFile(), MboxFile.READ_ONLY);

            InputStream oInStrm = oMbox.getPartAsStream(lPos, lOff, iLen);
            oMimeBody = new MimeBodyPart(oInStrm);
            oInStrm.close();

            oMbox.close();
          }
          else {
            if (DebugFile.trace) DebugFile.decIdent();
            throw new MessagingException("Part " + String.valueOf(iPartId) + " not found for message " + getMessage().getContentID());
          }
        } // fi (MODE_MBOX)
      } else {
        if (DebugFile.trace) {
          if (null==oFldr)
            DebugFile.writeln("Part "+String.valueOf(iPartId) + " not found in message ["+getMessage().getMessageGuid()+"] " + getMessage().getContentID());
          else
            DebugFile.writeln("Part "+String.valueOf(iPartId) + " not found in message ["+getMessage().getMessageGuid()+"] " + getMessage().getContentID() + " at folder " + oFldr.getCategoryGuid());
        }
      } // fi (oRset.next();

      oRSet.close();
      oRSet = null;
      oStmt.close();
      oStmt = null;
    } catch (SQLException sqle) {
      try { if (null!=oRSet) oRSet.close(); } catch (Exception ignore) {}
      try { if (null!=oStmt) oStmt.close(); } catch (Exception ignore) {}
      throw new MessagingException(sqle.getMessage(), sqle);
    } catch (com.enterprisedt.net.ftp.FTPException xcpt) {
      try { if (null!=oRSet) oRSet.close(); } catch (Exception ignore) {}
      try { if (null!=oStmt) oStmt.close(); } catch (Exception ignore) {}
      throw new MessagingException(xcpt.getMessage(), xcpt);
    }

    if (oMimeBody!=null) {
      if (DebugFile.trace) DebugFile.writeln("MimeBodyPart.getContent()");
      oRetVal = oMimeBody.getContent();
View Full Code Here

          if (!oRSet.wasNull()) iLenPart = oRSet.getInt(5);
          oOffset = oRSet.getObject(6);
          if (!oRSet.wasNull()) iOffset = oRSet.getInt(6);

          if (iPosition!=-1) {
            if (iLenPart==-1) throw new MessagingException("Part " + String.valueOf(iPartId) + " length not set at k_mime_parts table");
            if (iOffset==-1 ) throw new MessagingException("Part " + String.valueOf(iPartId) + " offset not set at k_mime_parts table");

            if (DebugFile.trace) DebugFile.writeln("new MboxFile("+((DBFolder)getMessage().getFolder()).getFile()+")");

            MboxFile oMbox = new MboxFile(((DBFolder)getMessage().getFolder()).getFile(), MboxFile.READ_ONLY);

            oMimeBody = new MimeBodyPart(oMbox.getPartAsStream(iPosition, iOffset, iLenPart));

            oMbox.close();
          }
          else {
            if (DebugFile.trace) DebugFile.decIdent();
            throw new MessagingException("Part " + String.valueOf(iPartId) + " not found for message " + getMessage().getContentID());
          }
        } // fi (MODE_MBOX)
      } // fi (oRset.next();

      oRSet.close();
      oRSet = null;
      oStmt.close();
      oStmt = null;
    } catch (SQLException sqle) {
      try { if (null!=oRSet) oRSet.close(); } catch (Exception ignore) {}
      try { if (null!=oStmt) oStmt.close(); } catch (Exception ignore) {}
      throw new MessagingException(sqle.getMessage(), sqle);
    }

    if (oMimeBody!=null) oRetVal = oMimeBody.getInputStream();

    if (DebugFile.trace) {
View Full Code Here

      }
      catch (SQLException sqle) {
        sFileName = null;
        if (oStmt!=null) { try { oStmt.close(); } catch (Exception ignore) {} }
        if (DebugFile.trace) DebugFile.decIdent();
        throw new MessagingException(sqle.getMessage(), sqle);
      }
    }
    else {
      sFileName = null;
    }
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.