com.amazonaws.services.simpleemail.model.Body类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(11.7k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中com.amazonaws.services.simpleemail.model.Body类的一些代码示例,展示了Body类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Body类的具体详情如下:
包路径:com.amazonaws.services.simpleemail.model.Body
类名称:Body

Body介绍

[英]Represents the body of the message. You can specify text, HTML, or both. If you use both, then the message should display correctly in the widest variety of email clients.
[中]表示消息的正文。您可以指定文本、HTML或两者。如果您同时使用这两种方式,那么邮件应该在最广泛的电子邮件客户端中正确显示。

代码示例

代码示例来源:origin: aws/aws-sdk-java

public Body unmarshall(StaxUnmarshallerContext context) throws Exception {
  Body body = new Body();
  int originalDepth = context.getCurrentDepth();
  int targetDepth = originalDepth + 1;
  if (context.isStartOfDocument())
    targetDepth += 1;
  while (true) {
    XMLEvent xmlEvent = context.nextEvent();
    if (xmlEvent.isEndDocument())
      return body;
    if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) {
      if (context.testExpression("Text", targetDepth)) {
        body.setText(ContentStaxUnmarshaller.getInstance().unmarshall(context));
        continue;
      }
      if (context.testExpression("Html", targetDepth)) {
        body.setHtml(ContentStaxUnmarshaller.getInstance().unmarshall(context));
        continue;
      }
    } else if (xmlEvent.isEndElement()) {
      if (context.getCurrentDepth() < originalDepth) {
        return body;
      }
    }
  }
}

代码示例来源:origin: aws/aws-sdk-java

@Override
public boolean equals(Object obj) {
  if (this == obj)
    return true;
  if (obj == null)
    return false;
  if (obj instanceof Body == false)
    return false;
  Body other = (Body) obj;
  if (other.getText() == null ^ this.getText() == null)
    return false;
  if (other.getText() != null && other.getText().equals(this.getText()) == false)
    return false;
  if (other.getHtml() == null ^ this.getHtml() == null)
    return false;
  if (other.getHtml() != null && other.getHtml().equals(this.getHtml()) == false)
    return false;
  return true;
}

代码示例来源:origin: org.duracloud/notification-amazon

@Override
public void sendAsHtml(String subject, String body, String... recipients) {
  Body requestBody = new Body().withHtml(new Content(body));
  sendEmail(subject, requestBody, recipients);
}

代码示例来源:origin: kodokojo/kodokojo

private void sendSimpleMail(List<String> to, List<String> cc, List<String> ci, String object, String content, boolean htmlContent) {
  Destination destination = new Destination().withToAddresses(to).withBccAddresses(ci).withCcAddresses(cc);
  Content subject = new Content().withData(object);
  Content bodyContent = new Content().withData(content);
  Body body;
  if (htmlContent) {
    body = new Body().withHtml(bodyContent);
  } else {
    body = new Body().withText(bodyContent);
  }
  Message message = new Message().withSubject(subject).withBody(body);
  SendEmailRequest request = new SendEmailRequest().withSource(from).withDestination(destination).withMessage(message);
  try {
    AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient();
    client.setRegion(region);
    client.sendEmail(request);
  } catch (Exception e) {
    LOGGER.error("Unable to send email to {} with subject '{}'", StringUtils.join(to, ","), subject, e);
  }
}

代码示例来源:origin: org.duracloud/notification-amazon

@Override
public void send(String subject, String body, String... recipients) {
  Body requestBody = new Body().withText(new Content(body));
  sendEmail(subject, requestBody, recipients);
}

代码示例来源:origin: kaif-open/kaif

Message message = new Message();
message.setSubject(new Content(mailMessage.getSubject()).withCharset(Charsets.UTF_8.toString()));
message.setBody(new Body(new Content(mailMessage.getText()).withCharset(Charsets.UTF_8.toString())));

代码示例来源:origin: aws/aws-sdk-java

@Override
public boolean equals(Object obj) {
  if (this == obj)
    return true;
  if (obj == null)
    return false;
  if (obj instanceof Message == false)
    return false;
  Message other = (Message) obj;
  if (other.getSubject() == null ^ this.getSubject() == null)
    return false;
  if (other.getSubject() != null && other.getSubject().equals(this.getSubject()) == false)
    return false;
  if (other.getBody() == null ^ this.getBody() == null)
    return false;
  if (other.getBody() != null && other.getBody().equals(this.getBody()) == false)
    return false;
  return true;
}

代码示例来源:origin: micronaut-projects/micronaut-examples

private Body bodyOfEmail(Email email) {
  if (email.getHtmlBody() != null) {
    Content htmlBody = new Content().withData(email.getHtmlBody());
    return new Body().withHtml(htmlBody);
  }
  if (email.getTextBody() != null) {
    Content textBody = new Content().withData(email.getTextBody());
    return new Body().withHtml(textBody);
  }
  return new Body();
}

代码示例来源:origin: com.cosmicpush/push-server-plugin-ses

String apiMessage = null;
Body body = new Body();
if (StringUtils.isBlank(push.getHtmlContent())) {
 body.withText(new Content().withCharset("UTF-8").withData("-no message-"));
} else {
 body.withHtml(new Content().withCharset("UTF-8").withData(push.getHtmlContent()));

代码示例来源:origin: spring-cloud/spring-cloud-aws

private SendEmailRequest prepareMessage(SimpleMailMessage simpleMailMessage) {
    Destination destination = new Destination();
    destination.withToAddresses(simpleMailMessage.getTo());

    if (simpleMailMessage.getCc() != null) {
      destination.withCcAddresses(simpleMailMessage.getCc());
    }

    if (simpleMailMessage.getBcc() != null) {
      destination.withBccAddresses(simpleMailMessage.getBcc());
    }

    Content subject = new Content(simpleMailMessage.getSubject());
    Body body = new Body(new Content(simpleMailMessage.getText()));

    SendEmailRequest emailRequest = new SendEmailRequest(simpleMailMessage.getFrom(), destination, new Message(subject, body));

    if (StringUtils.hasText(simpleMailMessage.getReplyTo())) {
      emailRequest.withReplyToAddresses(simpleMailMessage.getReplyTo());
    }

    return emailRequest;
  }
}

代码示例来源:origin: aws-amplify/aws-sdk-android

@Override
  public boolean equals(Object obj) {
    if (this == obj)
      return true;
    if (obj == null)
      return false;

    if (obj instanceof Message == false)
      return false;
    Message other = (Message) obj;

    if (other.getSubject() == null ^ this.getSubject() == null)
      return false;
    if (other.getSubject() != null && other.getSubject().equals(this.getSubject()) == false)
      return false;
    if (other.getBody() == null ^ this.getBody() == null)
      return false;
    if (other.getBody() != null && other.getBody().equals(this.getBody()) == false)
      return false;
    return true;
  }
}

代码示例来源:origin: com.erudika/para-server

@Override
  public boolean sendEmail(List<String> emails, String subject, String body) {
    if (emails != null && !emails.isEmpty() && !StringUtils.isBlank(body)) {
      final SendEmailRequest request = new SendEmailRequest().withSource(Config.SUPPORT_EMAIL);
      Destination dest = new Destination().withToAddresses(emails);
      request.setDestination(dest);

      Content subjContent = new Content().withData(subject);
      Message msg = new Message().withSubject(subjContent);

      // Include a body in both text and HTML formats
      Content textContent = new Content().withData(body).withCharset(Config.DEFAULT_ENCODING);
      msg.setBody(new Body().withHtml(textContent));

      request.setMessage(msg);

      Para.asyncExecute(new Runnable() {
        public void run() {
          sesclient.sendEmail(request);
        }
      });
      return true;
    }
    return false;
  }
}

代码示例来源:origin: aws-amplify/aws-sdk-android

public Body unmarshall(StaxUnmarshallerContext context) throws Exception {
  Body body = new Body();
  int originalDepth = context.getCurrentDepth();
  int targetDepth = originalDepth + 1;
  if (context.isStartOfDocument())
    targetDepth += 2;
  while (true) {
    int xmlEvent = context.nextEvent();
    if (xmlEvent == XmlPullParser.END_DOCUMENT)
      break;
    if (xmlEvent == XmlPullParser.START_TAG) {
      if (context.testExpression("Text", targetDepth)) {
        body.setText(ContentStaxUnmarshaller.getInstance().unmarshall(context));
        continue;
      }
      if (context.testExpression("Html", targetDepth)) {
        body.setHtml(ContentStaxUnmarshaller.getInstance().unmarshall(context));
        continue;
      }
    } else if (xmlEvent == XmlPullParser.END_TAG) {
      if (context.getCurrentDepth() < originalDepth) {
        break;
      }
    }
  }
  return body;
}

代码示例来源:origin: org.springframework.cloud/spring-cloud-aws-context

private SendEmailRequest prepareMessage(SimpleMailMessage simpleMailMessage) {
    Destination destination = new Destination();
    destination.withToAddresses(simpleMailMessage.getTo());

    if (simpleMailMessage.getCc() != null) {
      destination.withCcAddresses(simpleMailMessage.getCc());
    }

    if (simpleMailMessage.getBcc() != null) {
      destination.withBccAddresses(simpleMailMessage.getBcc());
    }

    Content subject = new Content(simpleMailMessage.getSubject());
    Body body = new Body(new Content(simpleMailMessage.getText()));

    SendEmailRequest emailRequest = new SendEmailRequest(simpleMailMessage.getFrom(), destination, new Message(subject, body));

    if (StringUtils.hasText(simpleMailMessage.getReplyTo())) {
      emailRequest.withReplyToAddresses(simpleMailMessage.getReplyTo());
    }

    return emailRequest;
  }
}

代码示例来源:origin: aws/aws-sdk-java

@Override
public int hashCode() {
  final int prime = 31;
  int hashCode = 1;
  hashCode = prime * hashCode + ((getText() == null) ? 0 : getText().hashCode());
  hashCode = prime * hashCode + ((getHtml() == null) ? 0 : getHtml().hashCode());
  return hashCode;
}

代码示例来源:origin: com.amazonaws/aws-java-sdk-ses

@Override
public boolean equals(Object obj) {
  if (this == obj)
    return true;
  if (obj == null)
    return false;
  if (obj instanceof Message == false)
    return false;
  Message other = (Message) obj;
  if (other.getSubject() == null ^ this.getSubject() == null)
    return false;
  if (other.getSubject() != null && other.getSubject().equals(this.getSubject()) == false)
    return false;
  if (other.getBody() == null ^ this.getBody() == null)
    return false;
  if (other.getBody() != null && other.getBody().equals(this.getBody()) == false)
    return false;
  return true;
}

代码示例来源:origin: Erudika/para

@Override
  public boolean sendEmail(List<String> emails, String subject, String body) {
    if (emails != null && !emails.isEmpty() && !StringUtils.isBlank(body)) {
      final SendEmailRequest request = new SendEmailRequest().withSource(Config.SUPPORT_EMAIL);
      Destination dest = new Destination().withToAddresses(emails);
      request.setDestination(dest);

      Content subjContent = new Content().withData(subject);
      Message msg = new Message().withSubject(subjContent);

      // Include a body in both text and HTML formats
      Content textContent = new Content().withData(body).withCharset(Config.DEFAULT_ENCODING);
      msg.setBody(new Body().withHtml(textContent));

      request.setMessage(msg);

      Para.asyncExecute(new Runnable() {
        public void run() {
          sesclient.sendEmail(request);
        }
      });
      return true;
    }
    return false;
  }
}

代码示例来源:origin: com.amazonaws/aws-java-sdk-ses

public Body unmarshall(StaxUnmarshallerContext context) throws Exception {
  Body body = new Body();
  int originalDepth = context.getCurrentDepth();
  int targetDepth = originalDepth + 1;
  if (context.isStartOfDocument())
    targetDepth += 1;
  while (true) {
    XMLEvent xmlEvent = context.nextEvent();
    if (xmlEvent.isEndDocument())
      return body;
    if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) {
      if (context.testExpression("Text", targetDepth)) {
        body.setText(ContentStaxUnmarshaller.getInstance().unmarshall(context));
        continue;
      }
      if (context.testExpression("Html", targetDepth)) {
        body.setHtml(ContentStaxUnmarshaller.getInstance().unmarshall(context));
        continue;
      }
    } else if (xmlEvent.isEndElement()) {
      if (context.getCurrentDepth() < originalDepth) {
        return body;
      }
    }
  }
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
 * redacted from this string using a placeholder value.
 *
 * @return A string representation of this object.
 *
 * @see java.lang.Object#toString()
 */
@Override
public String toString() {
  StringBuilder sb = new StringBuilder();
  sb.append("{");
  if (getText() != null)
    sb.append("Text: ").append(getText()).append(",");
  if (getHtml() != null)
    sb.append("Html: ").append(getHtml());
  sb.append("}");
  return sb.toString();
}

代码示例来源:origin: com.erudika/para

@Override
  public boolean sendEmail(List<String> emails, String subject, String body) {
    if (emails != null && !emails.isEmpty() && !StringUtils.isBlank(body)) {
      final SendEmailRequest request = new SendEmailRequest().withSource(Config.SUPPORT_EMAIL);
      Destination dest = new Destination().withToAddresses(emails);
      request.setDestination(dest);

      Content subjContent = new Content().withData(subject);
      Message msg = new Message().withSubject(subjContent);

      // Include a body in both text and HTML formats
      Content textContent = new Content().withData(body).withCharset(Config.DEFAULT_ENCODING);
      msg.setBody(new Body().withHtml(textContent));

      request.setMessage(msg);

      Utils.asyncExecute(new Runnable() {
        public void run() {
          sesclient.sendEmail(request);
        }
      });
      return true;
    }
    return false;
  }
}

相关文章