Package javax.mail

Examples of javax.mail.Session


                      String   mimeType )
        throws NamingException,
                   MessagingException
    {
        InitialContext ic = new InitialContext(  );
        Session        session = ( Session ) ic.lookup( _jndiSession );
        Message        msg = new MimeMessage( session );

        if ( from != null )
        {
            msg.setFrom( from );
View Full Code Here


    if (mUser != null)
    {
      props.put("mail.smtp.auth", "true");
    }
    Authenticator auth = new MyAuthenticator();
    Session session = Session.getInstance(props, auth);
    try
    {
      /*
       * Creating the message
       */
 
View Full Code Here

         final String mbox = "INBOX";
         // Get a Properties object
         Properties props = System.getProperties();

         // Get a Session object
         Session session = Session.getInstance(props, null);
         session.setDebug(debug);

         // Get a Store object
         Store store = null;
         if (url != null) {
            URLName urln = new URLName(url);
            store = session.getStore(urln);
            if (showAlert) {
               store.addStoreListener(new StoreListener() {
                  public void notification(StoreEvent e) {
                     String s;
                     if (e.getMessageType() == StoreEvent.ALERT)
View Full Code Here

  public int importMbox(String sMboxFilePath)
    throws FileNotFoundException, IOException, MessagingException {

    MimeMessage oMsg;
    InputStream oMsgStrm;
    Session oSession = ((DBStore)getStore()).getSession();
    MboxFile oInputMbox = new MboxFile(sMboxFilePath, MboxFile.READ_ONLY);

    final int iMsgCount = oInputMbox.getMessageCount();

    for (int m=0; m<iMsgCount; m++) {
View Full Code Here

      DebugFile.incIdent();
    }

    try {
      ByteArrayOutputStream byOutStrm = null;
      Session oSession = ((DBStore)getStore()).getSession();
      String sGuWorkArea = ((DBStore)getStore()).getUser().getString(DB.gu_workarea);
      String sGuFolder = getCategoryGuid();
      oInputMbox = new MboxFile(sMboxFilePath, MboxFile.READ_ONLY);
      DBSubset oMsgs = new DBSubset (DB.k_mime_msgs, DB.gu_mimemsg+","+DB.gu_workarea, DB.gu_category+"=?", 1000);
      oConn = getConnection();
View Full Code Here

      matcher.find();
      if( matcher.groupCount()>0 ) {
        // We found a message url. Determine the message UID from the url.
        int messageUID = Integer.parseInt(matcher.group(3));
        mLog.debug("Read mime message uid: " + messageUID + " for IMAP url: " + url);
        Session session = Session.getInstance(new Properties());
   
        URLName originURLName = new URLName(ImapToolkit.cutMessageIdentifier(
          CrawlerToolkit.replaceAuthenticationValuesInURL(url, mAccountPasswordEntry)));
        // Replace all %20 with whitespace in folder pathes
        String folder = "";
View Full Code Here

    }
    assertNotSame("BigAttachmentTest: To complete this test you must change the BIGFILE_PATH var to point out a file on your disk !", TO_CHANGE, BIGFILE_PATH);
    Properties props = System.getProperties();
    props.setProperty("mail.smtp.host", "localhost");
    props.setProperty("mail.smtp.port", SMTP_PORT+"");
    Session session = Session.getInstance(props);

    MimeMessage baseMsg = new MimeMessage(session);
    MimeBodyPart bp1 = new MimeBodyPart();
    bp1.setHeader("Content-Type", "text/plain");
    bp1.setContent("Hello World!!!", "text/plain; charset=\"ISO-8859-1\"");
View Full Code Here

   * @throws RegainException If encoding of the found URLs failed.
   */
  private void parseIMAPFolder(String folderUrl) throws RegainException {

    mLog.debug("Determine IMAP subfolder for: " + folderUrl);
    Session session = Session.getInstance(new Properties());

    URLName originURLName = new URLName(
      CrawlerToolkit.replaceAuthenticationValuesInURL(folderUrl,
      CrawlerToolkit.findAuthenticationValuesForURL(folderUrl, accountPasswordStore)));
    // Replace all %20 with whitespace in folder pathes
View Full Code Here

  {
    try
    {
      MimeMessage[] mimeMessages = new MimeMessage[2];
      Properties mailProps = this.getMailProperties(SMTP_PORT);
      Session session = Session.getInstance(mailProps, null);
      // session.setDebug(true);

      mimeMessages[0] = this.createMessage(session, "sender@whatever.com", "receiver@home.com", "Doodle1", "Bug1");
      mimeMessages[1] = this.createMessage(session, "sender@whatever.com", "receiver@home.com", "Doodle2", "Bug2");

      Transport transport = session.getTransport("smtp");
      transport.connect("localhost", SMTP_PORT, null, null);

      for (MimeMessage mimeMessage : mimeMessages)
      {
        transport.sendMessage(mimeMessage, mimeMessage.getAllRecipients());
View Full Code Here

      String From = "sender@here.com";
      String To = "receiver@there.com";
      String Subject = "Test";
      String body = "Test Body";

      Session session = Session.getInstance(this.getMailProperties(SMTP_PORT), null);
      Message msg = new MimeMessage(session);
      msg.setFrom(new InternetAddress(From));
      msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(To, false));
      msg.setSubject(Subject);

      msg.setText(body);
      msg.setHeader("X-Mailer", "musala");
      msg.setSentDate(new Date());

      Transport transport = null;

      try
      {
        transport = session.getTransport("smtp");
        transport.connect(HOST_NAME, SMTP_PORT, "ddd", "ddd");
        assertEquals(0, this.server.getMessages().size());
        transport.sendMessage(msg, InternetAddress.parse(To, false));
        assertEquals(1, this.server.getMessages().size());
        transport.sendMessage(msg, InternetAddress.parse("dimiter.bakardjiev@musala.com", false));
View Full Code Here

TOP

Related Classes of javax.mail.Session

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.