Just getting to play around with the new button field (it’s awesome) and had a quick question - any idea if it’s possible pull multiple emails into the “To” section of the email?
To explain further, I have two 2 tables within a base: 1 is locations and 1 is contacts. On the locations table, each location has multiple contacts linked it. I’m looking to build a button that when clicked, would include all of the contacts associated to that location into the “To” section of an email.
Thanks for taking the time to chime in. The problem I’m having is as follows:
Using the button tool, I am able to copy the email addresses from the Lookup column displaying them and have them inserted into the “to” section of the email - but even though they have commas in Airtable, they are being spit out in the to section without a separator (ie. email@example.com@test.com)
I’ve tried using both the Lookup and Rollup columns in this formula (pulling from the same property on the other table) and both spit out the emails without a separator between them.
I’ve included images of the the formula and what the final output looks like:
With a rollup field, use the aggregation formula: ARRAYJOIN(values, ",") . That will force a comma between the addresses. The same would work with a lookup field, but this function would need to be part of the button field formula, to process the array from the lookup field.
That aside, I see that you’re trying to insert this into a URL to Gmail. That adds a whole new wrinkle into the process, one which you should’ve mentioned earlier. :winking_face: I thought you were building a standard “mailto” link, not a website URL. With that in mind, you’ll also need to wrap the addresses in ENCODE_URL_COMPONENT() so that the non-alphanumeric symbols are properly encoded for the URL. The same will also need to be done for the other values passed to the URL.
If you use the lookup field shown in your screenshot, then your formula would look like this (broken up on several lines for clarity:
This is super helpful - thank you so so much for clarifying in detail. For what it’s worth (and likely because I’m doing something wrong on my end), this button does not work when inserting the ARRAYJOIN function straight into the rollup column aggregation formula (button is greyed out and not clickable) but it works perfectly with the Lookup column (inserting ARRAYJOIN into the button’s URL formula).
The final question on this - I’ve tried using “\n” to skip lines in the & “&body=” section of the button URL but it doesn’t seem to be picking it up. Am I doing something wrong or does the button URL formula not accept line skips?
Airtable formulas do accept the newline escape code “\n”, but Airtable doesn’t always display them properly in every location. If the record height in your table is only one line, for example, you won’t see newlines.
However, if you’re talking about the newlines not getting through to Gmail, that may be something else. It’s possible that Gmail is expecting HTML instead of plain text, in which case you might try wrapping your paragraphs in standard HTML paragraph tags. I don’t have time at the moment to test this theory, but I’d be interested to hear what you find if you do try it.
Some snooping around and additional guidance from @JonathanBowen led me to the solution here - the “\n” line break code needs to be within the ENCODE_URL_COMPONENT section for the line break action to carry over to Gmail. As I had it, I had closed the parenthesis of that section and included the \n after it.