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


Java AmazonSimpleEmailServiceClient.setRegion方法代码示例

本文整理汇总了Java中com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.setRegion方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonSimpleEmailServiceClient.setRegion方法的具体用法?Java AmazonSimpleEmailServiceClient.setRegion怎么用?Java AmazonSimpleEmailServiceClient.setRegion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient的用法示例。


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

示例1: sendSimpleMail

import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; //导入方法依赖的package包/类
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);
        }
    }
 
开发者ID:kodokojo,项目名称:kodokojo,代码行数:22,代码来源:SesEmailSender.java

示例2: initClients

import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; //导入方法依赖的package包/类
private void initClients() {
    AWSCredentials credentials = AmazonSharedPreferencesWrapper
            .getCredentialsFromSharedPreferences(this.sharedPreferences);

    Region region = Region.getRegion(Regions.US_EAST_1);

    sesClient = new AmazonSimpleEmailServiceClient(credentials);
    sesClient.setRegion(region);
}
 
开发者ID:pgodzin,项目名称:ExerciseMe,代码行数:10,代码来源:AmazonClientManager.java

示例3: send

import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; //导入方法依赖的package包/类
@Override
public void send(List<String> to, List<String> cc, List<String> ci, String object, String content, boolean htmlContent, Set<Attachment> attachments) {
    if (CollectionUtils.isEmpty(to)) {
        throw new IllegalArgumentException("to must be defined.");
    }
    if (isBlank(content)) {
        throw new IllegalArgumentException("content must be defined.");
    }

    if (attachments == null) {
        sendSimpleMail(to, cc, ci, object, content, htmlContent);
    } else {
        Session session = Session.getDefaultInstance(new Properties());
        MimeMessage message = new MimeMessage(session);
        try {
            message.setSubject(object);
            message.setFrom(new InternetAddress(from));
            addRecipients(message, javax.mail.Message.RecipientType.TO, to);
            addRecipients(message, javax.mail.Message.RecipientType.CC, cc);
            addRecipients(message, javax.mail.Message.RecipientType.BCC, ci);

            MimeBodyPart wrap = new MimeBodyPart();
            MimeMultipart cover = new MimeMultipart("alternative");
            MimeBodyPart html = new MimeBodyPart();
            cover.addBodyPart(html);

            wrap.setContent(cover);

            MimeMultipart multiPartContent = new MimeMultipart("related");
            message.setContent(multiPartContent);
            multiPartContent.addBodyPart(wrap);

            for (Attachment attachment : attachments) {

                MimeBodyPart attachmentPart = new MimeBodyPart();

                attachmentPart.setHeader("Content-ID", "<" + attachment.getId() + ">");
                attachmentPart.setFileName(attachment.getFileName());
                attachmentPart.setContent(attachment.getContent(), attachment.mineType());

                multiPartContent.addBodyPart(attachmentPart);
            }

            html.setContent(content, MINE_TEXT_HTML);

            // Send the email.
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            message.writeTo(outputStream);
            RawMessage rawMessage = new RawMessage(ByteBuffer.wrap(outputStream.toByteArray()));

            SendRawEmailRequest rawEmailRequest = new SendRawEmailRequest(rawMessage);

            AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient();
            client.setRegion(region);

            client.sendRawEmail(rawEmailRequest);

        } catch (MessagingException | IOException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:kodokojo,项目名称:kodokojo,代码行数:63,代码来源:SesEmailSender.java


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