Gmail: Send an email with optional To / Email Address 2

Hello Makers, I’m using Gmail’s “Send an email”-module to one or two addresses. The second is optional and not always present, I tried using if and ifempty with null, but the module keeps failing with “Invalid email address in parameter ‘to’” when the second address is empty. It works fine with “copy recipient” but doesn’t with “to”. Thanks!

Hey @Zbulo,

Great to see your question here in the community! :slight_smile:

I just wanted to clarify that this is a community of Make users helping out and sharing knowledge. This means we don’t have access to any of your scenarios, organizations etc.
It’s therefore always best to share some screenshots so that the community can see what’s going on in your scenarios visually.

Detailed information could be provided for example by an:

  1. overview of your scenario setup (functions, mappings, variables etc.)
  2. the input area of the module you are having trouble with
  3. the output area of the module you are getting data from

Thank you!

In case you think this is not needed, please disregard this message. I have send this message by automation since you don’t have any attachments.

1 Like

Did you try putting a 1 in between the brackets for email address 1 and
a 2 in between the brackets for email address 2?

Also use ignore instead of null

1 Like

Thanks for your input.

  1. When an address exists, the email is being correctly send.
  2. It also works when it put the formula from address 2 into cc.
  3. I tested with ignore/space/false/null but all are resulting in fail.

Toggl the map button for the To section and try

split(email1@test.com, ifempty(email2@test.com;{{emptystring}}) ; ,)

2 Likes

Nice answer. For some reason my brain came up with:

{{remove(add(emptyarray; 1.`My First Email Value`; 1.`My Second Email Value`); null)}}

Both work (though…I’m thinking neither should be required for this simple use case :wink: ).

1 Like

Thanks for both your solutions. The map button was hunting me here.

It indeed really feels like a too complex approach for such a simple job at hand.

Did I get this wrong? It results in a bundle validation error:
image

Validation failed for 18 parameter(s).
Invalid email address in parameter 'to'.
Invalid email address in parameter 'to'.
Invalid email address in parameter 'to'.
Invalid email address in parameter 'to'.
Invalid email address in parameter 'to'.
Invalid email address in parameter 'to'.
Invalid email address in parameter 'to'.
Invalid email address in parameter 'to'.
Invalid email address in parameter 'to'.
Invalid email address in parameter 'to'.
Invalid email address in parameter 'to'.
Invalid email address in parameter 'to'.
Invalid email address in parameter 'to'.
Invalid email address in parameter 'to'.
Invalid email address in parameter 'to'.
Invalid email address in parameter 'to'.
Invalid email address in parameter 'to'.
Invalid email address in parameter 'to'.

This one did the job. :slight_smile:

3 Likes