Package javax.mail

Examples of javax.mail.Address


            // Construct the message
            MimeMessage message = new MimeMessage(emailSession);

            // Set the from address
            Address fromAddress = new InternetAddress(emailFrom);
            message.setFrom(fromAddress);

            // Parse and set the recipient addresses
            Address[] toAddresses = InternetAddress.parse(emailTo);
            message.setRecipients(Message.RecipientType.TO, toAddresses);
View Full Code Here


            // Construct the message
            MimeMessage message = new MimeMessage(emailSession);

            // Set the from address
            Address fromAddress = new InternetAddress(emailFrom);
            message.setFrom(fromAddress);

            // Parse and set the recipient addresses
            Address[] toAddresses = InternetAddress.parse(emailTo);
            message.setRecipients(Message.RecipientType.TO, toAddresses);
View Full Code Here

            // Construct the message
            MimeMessage message = new MimeMessage(emailSession);

            // Set the from address
            Address fromAddress = new InternetAddress(emailFrom);
            message.setFrom(fromAddress);

            // Parse and set the recipient addresses
            Address[] toAddresses = InternetAddress.parse(emailTo);
            message.setRecipients(Message.RecipientType.TO, toAddresses);
View Full Code Here

    MailService service = MailServiceFactory.getMailService();
    MailService.Message msg = new MailService.Message();

    String sender = null;
    if (message instanceof MimeMessage) {
      Address senderAddr = ((MimeMessage) message).getSender();
      if (senderAddr != null) {
        sender = senderAddr.toString();
      }
    }
    if (sender == null && message.getFrom() != null
        && message.getFrom().length > 0) {
      sender = message.getFrom()[0].toString();
View Full Code Here

        assertNull(builder.getMimeMessage().getFrom());

        builder.setFrom(null);
        Address[] array = null;
        final Address addr = InternetAddress.getLocalAddress(null);
        if (addr != null) {
            array = new Address[] {addr};
        }
        assertArrayEquals(array, builder.getMimeMessage().getFrom());
View Full Code Here

     *                            on the spool
     */
    public void sendMail(MimeMessage message) throws MessagingException {
        MailAddress sender = new MailAddress((InternetAddress)message.getFrom()[0]);
        Collection<MailAddress> recipients = new HashSet<MailAddress>();
        Address addresses[] = message.getAllRecipients();
        if (addresses != null) {
            for (int i = 0; i < addresses.length; i++) {
                // Javamail treats the "newsgroups:" header field as a
                // recipient, so we want to filter those out.
                if ( addresses[i] instanceof InternetAddress ) {
View Full Code Here

            }
            Address[] bcc = getBcc(exchange, normalizedMessage);
            if (bcc != null) {
                mimeMessage.setRecipients(Message.RecipientType.BCC, bcc);
            }
            Address from = getFrom(exchange, normalizedMessage);
            if (from != null) {
                mimeMessage.setFrom(from);
            }
            String text = getText(exchange, normalizedMessage);
            String html = getHtml(exchange, normalizedMessage);
View Full Code Here

        if (addresses == null) {
            return null;
        }

        if (addresses.length > 0) {
            Address addr = addresses[0];
            if (addr instanceof InternetAddress) {
                emailAddress = (InternetAddress)addr;
            }
        }
View Full Code Here

        final StringTokenizer expectedTokens = new StringTokenizer(expected, ",");
        while (expectedTokens.hasMoreTokens()) {
            final String expectedToken = expectedTokens.nextToken().trim();
            boolean hasMatched = false;
            for (int i = 0; i < actuals.length; i++) {
                final Address actual = actuals[i];
                hasMatched = doMatch(expectedToken, actual.toString());
                if (hasMatched) {
                    break;
                }
            }
            if (!hasMatched) {
View Full Code Here

            m.setRecipients(Message.RecipientType.BCC, new Address[0]);
           
            Iterator<Address> aIter = addressTable.keySet().iterator();

            while ( aIter.hasNext() ) {
                Address a = aIter.next();
                m.addRecipient(addressTable.get(a), a);
            }
           
            // Simple E-mail needs at least one TO address, so add one if there isn't one
            if ( m.getRecipients(Message.RecipientType.TO) == null ||
View Full Code Here

TOP

Related Classes of javax.mail.Address

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.