Package javax.mail

Examples of javax.mail.Address


                  {
                     MimeMessage message = new MimeMessage(session);
                     message.setContent(doKeywordExpansion(content), mimeType);
                     message.setSubject(doKeywordExpansion(subject));

                     Address from = new InternetAddress(fromAddress, fromName);
                     message.setFrom(from);
                     message.setReplyTo(new Address[]{from});

                     if (toAddresses != null)
                     {
View Full Code Here


        StringBuffer buf = new StringBuffer(80);

        for (int i = 0; i < addresses.length; i++)
        {
            Address address = addresses[i];
            buf.append(address.toString());
            // all except the last one
            if (i < addresses.length - 1)
            {
                buf.append(", ");
            }
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

        }
        else {
            try {
                String encoding = MimeUtility.mimeCharset("UTF-8");
                MimeMessage message = createMimeMessage();
                Address to;
                Address from;

                if (toName != null) {
                    to = new InternetAddress(toEmail, toName, encoding);
                }
                else {
View Full Code Here

     */
    public Address[] getFrom() throws MessagingException {
        if (headers == null) {
            loadHeaders();
        }
        Address from[] = getAddressHeader(RFC2822Headers.FROM);
        if(from == null) {
            from = getAddressHeader(RFC2822Headers.SENDER);
        }
        return from;
    }
View Full Code Here

    public Address[] getAllRecipients() throws MessagingException {
        if (headers == null) {
            loadHeaders();
        }
        Address toAddresses[] = getRecipients(RecipientType.TO);
        Address ccAddresses[] = getRecipients(RecipientType.CC);
        Address bccAddresses[] = getRecipients(RecipientType.BCC);
        Address newsAddresses[] = getRecipients(RecipientType.NEWSGROUPS);
        if(ccAddresses == null && bccAddresses == null && newsAddresses == null) {
            return toAddresses;
        }
        int i = (toAddresses == null ? 0 : toAddresses.length)
                + (ccAddresses == null ? 0 : ccAddresses.length)
                + (bccAddresses == null ? 0 : bccAddresses.length)
                + (newsAddresses == null ? 0 : newsAddresses.length);
        Address allAddresses[] = new Address[i];
        int j = 0;
        if (toAddresses != null) {
            System.arraycopy(toAddresses, 0, allAddresses, j, toAddresses.length);
            j += toAddresses.length;
        }
View Full Code Here

    public Address[] getReplyTo() throws MessagingException {
        if (headers == null) {
            loadHeaders();
        }
        Address replyTo[] = getAddressHeader(RFC2822Headers.REPLY_TO);
        if(replyTo == null) {
            replyTo = getFrom();
        }
        return replyTo;
    }
View Full Code Here

            // Put data from request into message
            msg.setText(mailmess.getMessagetext());
            msg.setSubject(mailmess.getSubject());

            Address fromAddr = new InternetAddress(mailmess.getAddrfrom(),
                    mailmess.getNamefrom());
            msg.setFrom(fromAddr);

            Address toAddr = new InternetAddress(mailmess.getAddrto(),
                    mailmess.getNameto());
            msg.addRecipient(Message.RecipientType.TO, toAddr);
            msg.addHeaderLine("Content-Type: text/html;");
      msg.saveChanges();
            // Send the message
View Full Code Here

     * @param normalizedMessage the normalized message from JBI
     * @throws javax.mail.MessagingException if the message could not be constructed or there was an error creating an address
     */
    public void prepareMessage(MimeMessage mimeMessage, MessageExchange exchange, NormalizedMessage normalizedMessage) throws javax.mail.MessagingException {
        try {
            Address to = getTo(exchange, normalizedMessage);
            if (to != null) {
                mimeMessage.setRecipient(Message.RecipientType.TO, to);
            }
            Address cc = getCc(exchange, normalizedMessage);
            if (cc != null) {
                mimeMessage.setRecipient(Message.RecipientType.CC, cc);
            }
            Address bcc = getBcc(exchange, normalizedMessage);
            if (bcc != null) {
                mimeMessage.setRecipient(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

                recipient = addressTo.substring(lastsemicolonIndex + 1);
                message.addRecipient(Message.RecipientType.TO,
                        new InternetAddress(recipient));
                log.info("recipient" + recipient);
            }
            Address a[] = message.getAllRecipients();
            for (int j = 0; j < a.length; j++)
            {
                log.info("address" + a[j]);
            }
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.