Package javax.mail

Examples of javax.mail.Transport.sendMessage()


       
        message.setSubject(subject);
        message.setText(emailBody.toString());
        Transport transport = session.getTransport("smtp");
        transport.connect(host, from, pass);
        transport.sendMessage(message, message.getAllRecipients());
        transport.close();
     
     }catch(MessagingException ex)
     {
       System.out.println(ex.getMessage());
View Full Code Here


      final URLName smtpUrlName = options.genSmtpUrlName();
      log.debug("Opening transport to: " + smtpUrlName);
      final Transport transport = session.getTransport(smtpUrlName);
      transport.connect(smtpUrlName.getHost(), smtpUrlName.getPort(),
          smtpUrlName.getUsername(), smtpUrlName.getPassword());
      transport.sendMessage(msg, msg.getAllRecipients());
      transport.close();
      log.info("Message sent");
    } catch (Exception e) {
      log.error("Unable to send message", e);
    } finally {
View Full Code Here

        for(Address to: addressTo) {
          try{
          //msg.setRecipients(RecipientType.TO,new Address[]{to});
          //Transport.send(msg);
            msg.setRecipients(RecipientType.TO,new Address[]{to});
            transport.sendMessage(msg,new Address[]{to});
          } catch (Exception e) {
            //messageSendFailed(e,msg);
            transport.close();
                transport.connect();
          }
View Full Code Here

      transport = session.getTransport(this.protocol);
      transport.connect(this.smtpHost, this.userName, this.passWord);
     
      for (int i = 0; i < mailMessage.length; ++i) {
        mailMessage[i].setSession(session);
        transport.sendMessage(mailMessage[i].getMessage(),mailMessage[i].getMessage().getAllRecipients());
      }
    } catch (Exception e) {
      log.error("发送多份邮件失败"+e.getMessage());
      e.printStackTrace();
      sendSuccess = false;
View Full Code Here

            if (!useSmtpAuth) {
                trans.connect();
            } else {
                trans.connect(sendVia, authUser, authPass);
            }
            trans.sendMessage(mail, mail.getAllRecipients());
            results.put("messageWrapper", new MimeMessageWrapper(session, mail));
            results.put("messageId", mail.getMessageID());
            trans.close();
        } catch (SendFailedException e) {
            // message code prefix may be used by calling services to determine the cause of the failure
View Full Code Here

            if (!useSmtpAuth) {
                trans.connect();
            } else {
                trans.connect(sendVia, authUser, authPass);
            }
            trans.sendMessage(mail, mail.getAllRecipients());
            results.put("messageWrapper", new MimeMessageWrapper(session, mail));
            results.put("messageId", mail.getMessageID());
            trans.close();
        } catch (SendFailedException e) {
            // message code prefix may be used by calling services to determine the cause of the failure
View Full Code Here

            if (!useSmtpAuth) {
                trans.connect();
            } else {
                trans.connect(sendVia, authUser, authPass);
            }
            trans.sendMessage(mail, mail.getAllRecipients());
            results.put("messageWrapper", new MimeMessageWrapper(session, mail));
            results.put("messageId", mail.getMessageID());
            trans.close();
        } catch (SendFailedException e) {
            // message code prefix may be used by calling services to determine the cause of the failure
View Full Code Here

            message.setContent(_body.toString(), _mimeType);
        }

        Transport transport = session.getTransport();
        transport.connect();
        transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO));
        transport.close();
    }

    public void setBody(String body) {
        setBody(body, _mimeType);
View Full Code Here

                // Avoid a loop if we are stuck
                nAddresses = remainingAddresses.length;

                try {
                    // Send to the list of remaining addresses, ignoring the addresses attached to the message
                    transport.sendMessage(message, remainingAddresses);
                } catch(SendFailedException ex) {
                    bFailedToSome=true;
                    sendex.setNextException(ex);

                    // Extract the remaining potentially good addresses
View Full Code Here

            responseMessage.setDataHandler(
                    new DataHandler(new ByteArrayDataSource(responseContentType, responseBuffer.toByteArray())));
            transport = session.getTransport(transportUri);
            transport.connect();
            responseMessage.saveChanges();
            transport.sendMessage(responseMessage, responseMessage.getAllRecipients());
        }
        catch (MessagingException ex) {
            throw new MailTransportException(ex);
        }
        finally {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.