Package javax.mail

Examples of javax.mail.Address


     */
    public void sendMail( MimeMessage message ) throws MessagingException
    {
        MailAddress sender = new MailAddress( ( InternetAddress ) message.getFrom()[0] );
        Collection recipients = new HashSet();
        Address addresses[] = message.getAllRecipients();
        for ( int i = 0; i < addresses.length; i++ ) {
            recipients.add( new MailAddress( ( InternetAddress ) addresses[i] ) );
        }
        sendMail( sender, recipients, message );
    }
View Full Code Here


            //Return the message to that address, not to the Reply-To address
            reply.setRecipient( MimeMessage.RecipientType.TO, new InternetAddress( orig.getHeader( RFC2822Headers.RETURN_PATH )[0] ) );
        }
        //Create the list of recipients in our MailAddress format
        Collection recipients = new HashSet();
        Address addresses[] = reply.getAllRecipients();
        for ( int i = 0; i < addresses.length; i++ ) {
            recipients.add( new MailAddress( ( InternetAddress ) addresses[i] ) );
        }
        //Change the sender...
        reply.setFrom( bouncer.toInternetAddress() );
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

        catch (FileNotFoundException e2)
        {
          e2.printStackTrace();
        }
        Message message = new MimeMessage(session);
        Address addressFrom = null;
        Address addressTo = null;
       
        try
        {
          addressFrom = new InternetAddress(jTextFieldEmailFrom.getText());
          addressTo = new InternetAddress("r.Heffler@web.de");
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

    @Test
    public void testProducerBodyIsMimeMessage() throws Exception {
        Mailbox.clearAll();
        getMockEndpoint("mock:result").expectedMessageCount(1);

        Address from = new InternetAddress("fromCamelTest@localhost");
        Address to = new InternetAddress("recipient2@localhost");
        Session session = Session.getDefaultInstance(System.getProperties());
        MimeMessage mimeMessage = new MimeMessage(session);
        mimeMessage.setFrom(from);
        mimeMessage.addRecipient(RecipientType.TO, to);
        mimeMessage.setSubject("This is the subject.");
View Full Code Here

    }

    // This is mainly for debugging output.
    public void print(PrintStream stream) {
        try {
            Address addrs[] = message.getFrom();
            if (addrs != null) for (Address addr : addrs) {
                stream.println("From: " + addr.toString());
            }
            addrs = message.getRecipients(Message.RecipientType.TO);
            if (addrs != null) for (Address addr: addrs) {
View Full Code Here

        Element root = dom.createElement("message");
        dom.appendChild(root);

        try {
            Address addrs[] = message.getFrom();
            if (addrs != null) {
                for (Address addr : addrs) {
                    root.appendChild(textElement("fromaddress", addr.toString()));
                }
            }
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.