Skip to content

Readme feedback - confusion around template id  #46

Closed

Description

@headwinds

This isn't a bug but it might help the next dev

In your readme, you list the following...

final String EMAIL_ID_WELCOME_EMAIL = "EMAIL-ID-HERE";
final String TEMPLATE_ID = "TEMPLATE-ID-HERE";

I was a bit confused about what the email id is - at first I thought I was looking for my account email id. I didn't realize that it was actually actually an email template id!

I was getting a missing template id error then I decided to try this...

final String TEMPLATE_ID = "tem_jWXqetc...";
final String EMAIL_ID_WELCOME_EMAIL = TEMPLATE_ID;

everything worked! I think this makes it's easier to see the relationship if in fact they are the same. But I could be wrong....

Personally, I think this signature might even better for a first experience with SendWithUs - fantastic service by the way - I'm a bit embarrassed that I struggled here - everything else was straight-forward

SendReceipt sendReceipt = sendwithusAPI.send(
                TEMPLATE_ID,
                recipientMap,
                senderMap,
                emailDataMap
        );

Activity

  1. headwinds commented on Feb 26, 2022

    @headwinds
    Author

    One more thing - I think its natural that once a dev sends an email to 1 person, they may want figure out how to send it to multiple. Without getting into personalization which could be its own recipe, I would have also liked to see a cc example.

    That's something I had to google, and couldn't find an example so came up with the following by looking at what setCcRecipients expects:

            String[] ccEmails = {"[email protected]", "[email protected]"};
            HashMap<String, Object>[] ccRecipientsMap = (HashMap<String, Object>[]) new HashMap[ccEmails.length];
    
            int i = 0;
            for ( String email : ccEmails){
                HashMap<String, Object> hashMap = new HashMap<String, Object>();
                hashMap.put("address", email);
                ccRecipientsMap[i] = hashMap;
                i++;
            }
    
           SendWithUsSendRequest request = new SendWithUsSendRequest()
                    .setEmailId(EMAIL_ID_WELCOME_EMAIL)
                    .setRecipient(recipientMap)
                    .setCcRecipients(ccRecipientsMap)
                    .setSender(senderMap)
                    .setEmailData(emailDataMap);
            SendReceipt sendReceipt = sendwithusAPI.send(request);
    

    Once you have the cc, bcc is a piece of cake!

    props to Tufan Görel's article from 2016 which demonstrates how to create a HashMap as a store - typically we see an ArrayList for this structure.

  2. demoore commented on Apr 4, 2022

    @demoore
    Member

    Thanks @headwinds! I really appreciate the level of detail you've gone into here.

    I've added your recommendations into #49 and hopefully simplified the example a bit (who needs two template IDs?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions