当前位置: 首页>>代码示例>>Java>>正文


Java RecipientType类代码示例

本文整理汇总了Java中javax.mail.Message.RecipientType的典型用法代码示例。如果您正苦于以下问题:Java RecipientType类的具体用法?Java RecipientType怎么用?Java RecipientType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RecipientType类属于javax.mail.Message包,在下文中一共展示了RecipientType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendMsg

import javax.mail.Message.RecipientType; //导入依赖的package包/类
public boolean sendMsg(String recipient, String subject, String content)
		throws MessagingException {
	// Create a mail object
	Session session = Session.getInstance(props, new Authenticator() {
		// Set the account information session,transport will send mail
		@Override
		protected PasswordAuthentication getPasswordAuthentication() {
			return new PasswordAuthentication(Constants.MAIL_USERNAME, Constants.MAIL_PASSWORD);
		}
	});
	session.setDebug(true);
	Message msg = new MimeMessage(session);
	try {
		msg.setSubject(subject);			//Set the mail subject
		msg.setContent(content,"text/html;charset=utf-8");
		msg.setFrom(new InternetAddress(Constants.MAIL_USERNAME));			//Set the sender
		msg.setRecipient(RecipientType.TO, new InternetAddress(recipient));	//Set the recipient
		Transport.send(msg);
		return true;
	} catch (Exception ex) {
		ex.printStackTrace();
		System.out.println(ex.getMessage());
		return false;
	}

}
 
开发者ID:ICT-BDA,项目名称:EasyML,代码行数:27,代码来源:JavaMail.java

示例2: sendMessage

import javax.mail.Message.RecipientType; //导入依赖的package包/类
public void sendMessage (Message oMsg,
                         Address[] aAdrFrom, Address[] aAdrReply,
                         Address[] aAdrTo, Address[] aAdrCc, Address[] aAdrBcc)
  throws NoSuchProviderException,SendFailedException,ParseException,
         MessagingException,NullPointerException {           	
  oMsg.addFrom(aAdrFrom);
  if (null==aAdrReply)
    oMsg.setReplyTo(aAdrReply);
  else
    oMsg.setReplyTo(aAdrFrom);
  if (aAdrTo!=null) oMsg.addRecipients(javax.mail.Message.RecipientType.TO, aAdrTo);
  if (aAdrCc!=null) oMsg.addRecipients(javax.mail.Message.RecipientType.CC, aAdrCc);
  if (aAdrBcc!=null) oMsg.addRecipients(javax.mail.Message.RecipientType.BCC, aAdrBcc);
  oMsg.setSentDate(new java.util.Date());
  Transport.send(oMsg);
}
 
开发者ID:sergiomt,项目名称:zesped,代码行数:17,代码来源:MailSessionHandler.java

示例3: sendEmail

import javax.mail.Message.RecipientType; //导入依赖的package包/类
private static void sendEmail(String fromEmail, String toEmail, String subject, String body, boolean html)
throws MessagingException{
	MimeMessage message = new MimeMessage(MAILING_SESSION);
	message.setFrom(new InternetAddress(fromEmail));
	InternetAddress[] addresses = InternetAddress.parse(toEmail);//one or more addresses
	message.addRecipients(RecipientType.TO, addresses);
	message.setReplyTo(addresses);
	message.setSubject(subject);
	String subType;
	if(html){
		subType = "html";
	}else{
		subType = "plain";
	}
	message.setText(body, "UTF-8", subType);
	Transport.send(message);
}
 
开发者ID:hotpads,项目名称:datarouter,代码行数:18,代码来源:DatarouterEmailTool.java

示例4: sendEmail

import javax.mail.Message.RecipientType; //导入依赖的package包/类
@Async("emailExecutor")
public void sendEmail(EmailVerifyCode code, User user) {
	LOGGER.info("Sending verify email to {} for {}", user.getEmail(), user.getId());
	try {
		mailSender.send(msg -> {
			msg.setFrom(emailSender());
			msg.setRecipients(RecipientType.TO, code.getEmail());
			msg.setSubject(subject());
			msg.setContent(FreeMarkerTemplateUtils.processTemplateIntoString(fmConfig.getTemplate("email/verify-code.ftl"), model(code, user)), "text/html");
		});
	} catch (Throwable e) {
		LOGGER.warn("Couldn't send verify email to {}", user.getEmail(), e);
		return;
	}
	LOGGER.info("Sent verify email to {}", user.getEmail());
}
 
开发者ID:yushijinhun,项目名称:akir,代码行数:17,代码来源:VerifyEmailSender.java

示例5: sendAccountActivateEmail

import javax.mail.Message.RecipientType; //导入依赖的package包/类
public static void sendAccountActivateEmail(String email, String uuid, int userId) {
  Session session;
  try {
    session = getSession();
    MimeMessage message = new MimeMessage(session);
    message.setSubject("������֤��");
    message.setSentDate(new Date());
    message.setFrom(new InternetAddress(FROM));
    message.setRecipient(RecipientType.TO, new InternetAddress(email));
    message.setContent("�����û�"+userId+":������֤��Ϊ��"+uuid,
        "text/html;charset=utf-8");
    message.saveChanges();
    Transport.send(message);
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:Luodian,项目名称:Higher-Cloud-Computing-Project,代码行数:18,代码来源:EmailUtils.java

示例6: run

import javax.mail.Message.RecipientType; //导入依赖的package包/类
@Override
public void run() {
    try {
        Multipart mainPart = new MimeMultipart("mixed");
        mainPart.addBodyPart(bodyDestination.get().getBodyPart());
        for (Future<EmailPartDocumentDestination> ad : attachmentDests) mainPart.addBodyPart(ad.get().getBodyPart());

        Message msg = tx.email.newMimeMessage();
        msg.setFrom(new InternetAddress(replacePlainTextParameters(fromPattern, params)));
        msg.addRecipient(RecipientType.TO, new InternetAddress(replacePlainTextParameters(toPattern, params)));
        msg.setSubject(replacePlainTextParameters(subjectPattern, params));
        msg.setContent(mainPart);
        msg.setSentDate(new Date());
        
        tx.email.send(msg);
    }
    catch (ExecutionException | InterruptedException | MessagingException e) { throw new RuntimeException(e); }
}
 
开发者ID:onestopconcept,项目名称:onestop-endpoints,代码行数:19,代码来源:EmailTask.java

示例7: getAddresses

import javax.mail.Message.RecipientType; //导入依赖的package包/类
private String getAddresses(MimeMessage mimeMessage, RecipientType recipientType) {
	try {
		Address[] addresses = mimeMessage.getRecipients(recipientType);
		if (addresses == null) {
			return null;
		}
		StringBuilder builder = new StringBuilder();
		Address[] arrayOfAddress1;
		int j = (arrayOfAddress1 = addresses).length;
		for (int i = 0; i < j; i++) {
			Address address = arrayOfAddress1[i];
			InternetAddress ia = (InternetAddress) address;
			builder.append(ia.getAddress()).append(";");
		}
		return builder.substring(0, builder.length() - 1);
	} catch (MessagingException e) {
	}
	return "";
}
 
开发者ID:quirinobrizi,项目名称:maileasy,代码行数:20,代码来源:MailTranslator.java

示例8: from

import javax.mail.Message.RecipientType; //导入依赖的package包/类
public static Mail from(Message message) throws MessagingException, IOException {
  Mail mail = new Mail();

  mail.from = InternetAddress.toString(message.getFrom());
  mail.to =  InternetAddress.toString(message.getRecipients(RecipientType.TO));
  mail.cc = InternetAddress.toString(message.getRecipients(RecipientType.CC));

  mail.subject = message.getSubject();
  mail.sentDate = message.getSentDate();
  mail.receivedDate = message.getReceivedDate();

  mail.messageNumber = message.getMessageNumber();

  if (message instanceof MimeMessage) {
    MimeMessage mimeMessage = (MimeMessage) message;
    // extract more informations
    mail.messageId = mimeMessage.getMessageID();
  }

  processMessageContent(message, mail);

  return mail;
}
 
开发者ID:camunda,项目名称:camunda-bpm-mail,代码行数:24,代码来源:Mail.java

示例9: createMessage

import javax.mail.Message.RecipientType; //导入依赖的package包/类
protected Message createMessage(SendMailRequest request, Session session) throws Exception {

    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress(request.getFrom(), request.getFromAlias()));
    message.setRecipients(RecipientType.TO, InternetAddress.parse(request.getTo()));

    if (request.getCc() != null) {
      message.setRecipients(RecipientType.CC, InternetAddress.parse(request.getCc()));
    }
    if (request.getBcc() != null) {
      message.setRecipients(RecipientType.BCC, InternetAddress.parse(request.getBcc()));
    }

    message.setSentDate(new Date());
    message.setSubject(request.getSubject());

    if (hasContent(request)) {
      createMessageContent(message, request);
    } else {
      message.setText("");
    }

    return message;
  }
 
开发者ID:camunda,项目名称:camunda-bpm-mail,代码行数:25,代码来源:SendMailConnector.java

示例10: messageWithCc

import javax.mail.Message.RecipientType; //导入依赖的package包/类
@Test
public void messageWithCc() throws MessagingException {

 MailConnectors.sendMail()
    .createRequest()
      .from("test")
      .to("[email protected]")
      .cc("[email protected]")
      .subject("subject")
    .execute();

  MimeMessage[] mails = greenMail.getReceivedMessages();
  assertThat(mails).hasSize(2);

  assertThat(mails[0].getRecipients(RecipientType.CC))
    .hasSize(1)
    .extracting("address").contains("[email protected]");
}
 
开发者ID:camunda,项目名称:camunda-bpm-mail,代码行数:19,代码来源:SendMailConnectorTest.java

示例11: messageWithBcc

import javax.mail.Message.RecipientType; //导入依赖的package包/类
@Test
public void messageWithBcc() throws MessagingException {

 MailConnectors.sendMail()
    .createRequest()
      .from("test")
      .to("[email protected]")
      .bcc("[email protected]")
      .subject("subject")
    .execute();

  MimeMessage[] mails = greenMail.getReceivedMessages();
  assertThat(mails).hasSize(2);

  assertThat(mails[0].getRecipients(RecipientType.TO))
    .hasSize(1)
    .extracting("address").contains("[email protected]");

  assertThat(mails[0].getRecipients(RecipientType.BCC)).isNull();
}
 
开发者ID:camunda,项目名称:camunda-bpm-mail,代码行数:21,代码来源:SendMailConnectorTest.java

示例12: main

import javax.mail.Message.RecipientType; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
    clearConfigProperties();

    final Email emailNormal = new Email();
    emailNormal.setFromAddress("lollypop", "[email protected]");
    // don't forget to add your own address here ->
    emailNormal.addRecipient("C.Cane", YOUR_GMAIL_ADDRESS, RecipientType.TO);
    emailNormal.setText("We should meet up!");
    emailNormal.setTextHTML("<b>We should meet up!</b><img src='cid:thumbsup'>");
    emailNormal.setSubject("hey");

    // add two text files in different ways and a black thumbs up embedded image ->
    emailNormal.addAttachment("dresscode.txt", new ByteArrayDataSource("Black Tie Optional", "text/plain"));
    emailNormal.addAttachment("location.txt", "On the moon!".getBytes(Charset.defaultCharset()), "text/plain");
    String base64String = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABeElEQVRYw2NgoAAYGxu3GxkZ7TY1NZVloDcAWq4MxH+B+D8Qv3FwcOCgtwM6oJaDMTAUXOhmuYqKCjvQ0pdoDrCnmwNMTEwakC0H4u8GBgYC9Ap6DSD+iewAoIPm0ctyLqBlp9F8/x+YE4zpYT8T0LL16JYD8U26+B7oyz4sloPwenpYno3DchCeROsUbwa05A8eB3wB4kqgIxOAuArIng7EW4H4EhC/B+JXQLwDaI4ryZaDSjeg5mt4LCcFXyIn1fdSyXJQVt1OtMWGhoai0OD8T0W8GohZifE1PxD/o7LlsPLiFNAKRrwOABWptLAcqc6QGDAHQEOAYaAc8BNotsJAOgAUAosG1AFA/AtUoY3YEFhKMAvS2AE7iC1+WaG1H6gY3gzE36hUFJ8mqzbU1dUVBBqQBzTgIDQRkWo5qCZdpaenJ0Zx1aytrc0DDB0foIG1oAYKqC0IZK8D4n1AfA6IzwPxXpCFoGoZVEUDaRGGUTAKRgEeAAA2eGJC+ETCiAAAAABJRU5ErkJggg==";
    emailNormal.addEmbeddedImage("thumbsup", parseBase64Binary(base64String), "image/png");

    // let's try producing and then consuming a MimeMessage ->
    final MimeMessage mimeMessage = Mailer.produceMimeMessage(emailNormal);
    final Email emailFromMimeMessage = new Email(mimeMessage);

    // note: the following statements will produce 6 new emails!
    sendMail(emailNormal);
    sendMail(emailFromMimeMessage); // should produce the exact same result as emailNormal!
}
 
开发者ID:viydaag,项目名称:dungeonstory-java,代码行数:26,代码来源:MailTestApp.java

示例13: Email

import javax.mail.Message.RecipientType; //导入依赖的package包/类
/**
 * Constructor, creates all internal lists. Populates default from, reply-to, to, cc and bcc if provided in the config file.
 */
public Email() {
	recipients = new ArrayList<>();
	embeddedImages = new ArrayList<>();
	attachments = new ArrayList<>();
	headers = new HashMap<>();

	if (hasProperty(DEFAULT_FROM_ADDRESS)) {
		setFromAddress((String) getProperty(DEFAULT_FROM_NAME), (String) getProperty(DEFAULT_FROM_ADDRESS));
	}
	if (hasProperty(DEFAULT_REPLYTO_ADDRESS)) {
		setReplyToAddress((String) getProperty(DEFAULT_REPLYTO_NAME), (String) getProperty(DEFAULT_REPLYTO_ADDRESS));
	}
	if (hasProperty(DEFAULT_TO_ADDRESS)) {
		addRecipient((String) getProperty(DEFAULT_TO_NAME), (String) getProperty(DEFAULT_TO_ADDRESS), RecipientType.TO);
	}
	if (hasProperty(DEFAULT_CC_ADDRESS)) {
		addRecipient((String) getProperty(DEFAULT_CC_NAME), (String) getProperty(DEFAULT_CC_ADDRESS), RecipientType.CC);
	}
	if (hasProperty(DEFAULT_BCC_ADDRESS)) {
		addRecipient((String) getProperty(DEFAULT_BCC_NAME), (String) getProperty(DEFAULT_BCC_ADDRESS), RecipientType.BCC);
	}
	if (hasProperty(DEFAULT_SUBJECT)) {
		setSubject((String) getProperty(DEFAULT_SUBJECT));
	}
}
 
开发者ID:QianWorks,项目名称:qianworks-meican,代码行数:29,代码来源:Email.java

示例14: sendResetPasswordEmail

import javax.mail.Message.RecipientType; //导入依赖的package包/类
/** 
 * ���������������ӵ��ʼ� 
 */  
public static void sendResetPasswordEmail(AcctUser user,String resetPassHref) {  
    Session session = getSession();  
    MimeMessage message = new MimeMessage(session);  
    try {  
        message.setSubject("�һ������ʻ�������");  
        message.setSentDate(new Date());  
        message.setFrom(new InternetAddress(FROM));  
        message.setRecipient(RecipientType.TO, new InternetAddress(user.getEmail()));  
        message.setContent("Ҫʹ���µ�����, ��ʹ������������������:<br/><a href='"+resetPassHref+"'>���������������</a> SpringBBS","text/html;charset=utf-8");  
        // �����ʼ�  
        Transport.send(message);  
    } catch (Exception e) {  
        e.printStackTrace();  
    }  
}
 
开发者ID:muzili90,项目名称:SpringBBS,代码行数:19,代码来源:EmailUtils.java

示例15: emailInvoiceLink

import javax.mail.Message.RecipientType; //导入依赖的package包/类
/**
 * Sends a link to the generated overall invoice in GCS.
 *
 * <p>Note the users receiving the e-mail should have access to the object or bucket, via an
 * authorization mechanism such as IAM.
 */
void emailInvoiceLink() {
  // TODO(larryruili): Add read permissions for appropriate buckets.
  try {
    String beamBucket = beamBucketUrl.replaceFirst("gs://", "");
    Message msg = emailService.createMessage();
    msg.setFrom(new InternetAddress(alertSenderAddress));
    for (String recipient : invoiceEmailRecipients) {
      msg.addRecipient(RecipientType.TO, new InternetAddress(recipient));
    }
    msg.setSubject(String.format("Domain Registry invoice data %s", yearMonth.toString()));
    msg.setText(
        String.format(
            "Link to invoice on GCS:\nhttps://storage.cloud.google.com/%s/%s",
            beamBucket,
            String.format(
                "%s%s-%s.csv",
                BillingModule.RESULTS_DIRECTORY_PREFIX,
                BillingModule.OVERALL_INVOICE_PREFIX,
                yearMonth.toString())));
    emailService.sendMessage(msg);
  } catch (MessagingException e) {
    // TODO(larryruili): Replace with retrier with final failure email settings.
    logger.warning(e, "E-mail service failed due to %s");
  }
}
 
开发者ID:google,项目名称:nomulus,代码行数:32,代码来源:BillingEmailUtils.java


注:本文中的javax.mail.Message.RecipientType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。