Package javax.mail

Examples of javax.mail.Session


   * @throws MimeParserException
   */
  public void parse(InputStream in) throws IOException, MimeParserException
  {
    this.message = new Message();
    Session session = Session.getDefaultInstance(props);

    try {
      this.mimeMessage = new MimeMessage(session, in);
      this.message.setFrom(getAddressList(mimeMessage.getFrom()));
      this.message.setTo(getAddressList(mimeMessage.getRecipients(RecipientType.TO)));
View Full Code Here


        assertEquals("2", mimeMessage.getHeader("X-Priority")[0]);
        assertEquals("subject", mimeMessage.getSubject());
    }

    protected MimeMessage createMimeMessage() {
        Session session = Session.getInstance(new Properties());
        return new MimeMessage(session);
    }
View Full Code Here

        assertEquals("2", mimeMessage.getHeader("X-Priority")[0]);
        assertEquals("subject", mimeMessage.getSubject());
    }

    protected MimeMessage createMimeMessage() {
        Session session = Session.getInstance(new Properties());
        return new MimeMessage(session);
    }
View Full Code Here

                public PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(login, pwd);
                }
            };
        }//else: no authentication
        Session session = Session.getInstance(props, pa);
// — Tạo đối tượng message
        Message msg = new MimeMessage(session);
// — Set các field FROM và TO
        msg.setFrom(new InternetAddress(from));
        msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(
View Full Code Here

                public PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(login, pwd);
                }
            };
        }//else: no authentication
        Session session = Session.getInstance(props, pa);
// — Tạo đối tượng message
        Message msg = new MimeMessage(session);
// — Set các field FROM và TO
        msg.setFrom(new InternetAddress("nguyenduong111090@gmail.com"));
        msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(
View Full Code Here

                public PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(login, pwd);
                }
            };
        }//else: no authentication
        Session session = Session.getInstance(props, pa);
// — Tạo đối tượng message
        Message msg = new MimeMessage(session);
// — Set các field FROM và TO
        msg.setFrom(new InternetAddress("nguyenduong111090@gmail.com"));
        msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(
View Full Code Here

    while(runIt) {
      try {
        disconnect(store, mainFolder);
       
        log.info("Connecting to store/floder...");
        final Session session = Session.getInstance(options.genProperties());
        session.setDebug(options.isDebug());
 
        final URLName imapUrlName = options.genImapUrlName();
        store = (IMAPStore) session.getStore(imapUrlName);
 
        final InternalConnectionListener connectionListener = new InternalConnectionListener();
        //store.addConnectionListener(connectionListener);
        store.connect(imapUrlName.getHost(), imapUrlName.getPort(), imapUrlName.getUsername(), imapUrlName.getPassword());
        mainFolder = (IMAPFolder) store.getFolder(options.getImapFolder());
View Full Code Here

   *            the file {@link Path}(s) that will be attached to the email (if any)
   */
  public void send(final String subject, final String message, final String from, final String[] to, final Path... paths) {
    try {
      log.info("Sending message...");
      final Session session = Session.getInstance(options.genProperties());
      final MimeMessage msg = new MimeMessage(session);
      msg.setFrom(new InternetAddress(from));
      final InternetAddress[] addresses = new InternetAddress[to.length];
      int toIndex = 0;
      for (String t : to) {
View Full Code Here

  private static String  _typeContenu  = Messages.getString("MailService.CFG_MailContentType"); //$NON-NLS-1$

  public static void sendMail(String source, String sourceName, String destination, String destinationName, String subject, String body) throws UnsupportedEncodingException, MessagingException {
    Properties properties = System.getProperties();
    properties.put("mail.smtp.host", _serveurSMTP); //$NON-NLS-1$
    Session session = Session.getDefaultInstance(properties, null);

    // Construire le message
    MimeMessage message = new MimeMessage(session);
    message.setFrom(new InternetAddress(source, sourceName));
View Full Code Here

  {
    try
    {
      // login to the IMAP server
      Properties props = new Properties();
      Session session = Session.getInstance(props, null);
      Store store = session.getStore("imap");
      store.connect(_server, _username, _password);
      setStore(store);

      setRootFolders(FolderData.toFolderData(this, store.getDefaultFolder().list()));
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.