Can I put attachments in Personalized Email Amazon SES API?

Viewed 260

I can't put attachments in builk email, personalized, with SES API.

and I can't find someone who did that, so my question is: is it possible?

What I had did: I already have created an Email Template - used CreateTemplate API. -I already have made SendBulkTemplatedEmail operation with all it's needs and it worked well. sending emails using the API. (without attachments);

I have seen in docs that I can put attachments in SES raw email, but I can not find anything saying about personalized emails...

why I want personalized? When I have 5 thousends emails to delivery and every one is different, like names...

"The SendBulkTemplatedEmail operation is useful for sending unique emails to multiple destinations in a single call to the Amazon SES API."

so I have split these 5 thousand in group of 50 which is my amazon limit for ses, and send this group of emails togethers, (50 emails different for each others). Things like name, and in my especific problem, for Different attachments.

public void sendEmailAWS(List<Object> someList, String templateName) throws Exception {

        String remetente = "email...";
        String dataFormat = "{\"name\":\"%s\"}";

        AmazonSimpleEmailService ses = getSES();

        List<BulkEmailDestination> bulkEmailDestinations = new ArrayList<BulkEmailDestination>();
        for (Object obj : someList) {
            Destination destination = new Destination();
            List<String> toAddresses = new ArrayList<String>();
            toAddresses.add(obj.getEmail());
            destination.setToAddresses(toAddresses);
            BulkEmailDestination bulkEmailDestination = new BulkEmailDestination();
            bulkEmailDestination.setDestination(destination);
            bulkEmailDestination.setReplacementTemplateData(String.format(
                        dataFormat,
                        obj.getName()
                    );
            bulkEmailDestinations.add(bulkEmailDestination);
        }

        SendBulkTemplatedEmailRequest bulkTemplatedEmailRequest = new SendBulkTemplatedEmailRequest();
        bulkTemplatedEmailRequest.withDestinations(bulkEmailDestinations);
        bulkTemplatedEmailRequest.withTemplate(templateName);
        bulkTemplatedEmailRequest.withDefaultTemplateData(String.format(dataFormat, ""));
        bulkTemplatedEmailRequest.withSource(remetente);
        try {
            ses.sendBulkTemplatedEmail(bulkTemplatedEmailRequest);
        } catch(Exception e) {
            log = LoggerFactory.getLogger(e.getClass());
            log.error(e.getMessage(), e.getCause());
        }
    } 
    ```
0 Answers
Related