transport.send (javamailMessage);
Transport.send (javamailMessage);
    public void send (EmailMessage message)        throws EmailException    {        MimeMessage      javamailMessage;        InternetAddress  addresses[];        Iterator         it;        MimeMultipart    body;        List             attachments;        int              totalAttachments;        Collection       to;        Collection       cc;        Collection       bcc;        MimeBodyPart     textPart;        MultipartSubtype multipartSubtype;        try        {            // Create the Java Mail API message.            javamailMessage = new MimeMessage (session);            // Create the body that will be put in the message, and set the            // multipart subtype.            body = new MimeMultipart();            multipartSubtype = message.getMultipartSubtype();            body.setSubType (multipartSubtype.getSubtypeString());            // Set the sender            EmailAddress senderAddress = message.getSender();            javamailMessage.setFrom (senderAddress.getInternetAddress());            // Set the various recipients.            to  = message.getToAddresses();            cc  = message.getCcAddresses();            bcc = message.getBccAddresses();            if (to.size() == 0)            {                throw new EmailException ("No \"To:\" addresses in message");            }            setRecipients (javamailMessage, Message.RecipientType.TO, to);            setRecipients (javamailMessage, Message.RecipientType.CC, cc);            setRecipients (javamailMessage, Message.RecipientType.BCC, bcc);            // Set the subject.            javamailMessage.setSubject (message.getSubject());            // Note: The Java Mail API wants *some* content. If the text            // part is null and there are no attachments, build an empty            // text part, so something is there.            attachments = message.getAttachments();            totalAttachments = attachments.size();            textPart = message.getTextPart();            if ( (textPart == null) && (totalAttachments == 0) )            {                message.setText ("");                textPart = message.getTextPart();            }            // Build the text part of the message.            if (textPart != null)                body.addBodyPart (textPart);            // Build the attachments.            if (totalAttachments > 0)            {                for (it = attachments.iterator(); it.hasNext(); )                    body.addBodyPart ((MimeBodyPart) it.next());            }            // Set the message body, if any.            if (body.getCount() > 0)                javamailMessage.setContent (body);            // Set additional headers.            for (it = message.getAdditionalHeaders().iterator();                 it.hasNext(); )            {                javamailMessage.addHeaderLine ((String) it.next());            }            // Set the sent date.            javamailMessage.setSentDate (new Date());            // Send it.            transport.connect();	    transport.send (javamailMessage);            transport.close();        }        catch (MessagingException ex)        {            throw new EmailException ("Unable to send message", ex);	}    }