bigfunctions > send_mail
send_mailΒΆ
Signature
send_mail(to, subject, content, attachment_filename, attachment_content)
Description
Sends an email
to to
email with subject
, content
and possible attachment (defined by attachment_filename
and attachment_content
).
Param | Possible values |
---|---|
to |
One or multiple comma separated emails. For instance contact@unytics.io or contact@unytics.io, paul.marcombes@unytics.io |
subject |
Email subject |
content |
Can be plain text, html or markdown |
attachment_filename |
null or filename with extension such as report.xlsx |
attachment_content |
null or can be plain text or base64 encoded content (useful to send excel files, pdf or images) |
This function uses SendGrid to send the emails and Lee Munroe HTML template for styling emails.
Examples
1. Send email without file attached
select bigfunctions.eu.send_mail('contact@unytics.io', 'I love BigFunctions', 'Hey Paul, could you deploy more BigFunctions π?', null, null)
select bigfunctions.us.send_mail('contact@unytics.io', 'I love BigFunctions', 'Hey Paul, could you deploy more BigFunctions π?', null, null)
select bigfunctions.europe_west1.send_mail('contact@unytics.io', 'I love BigFunctions', 'Hey Paul, could you deploy more BigFunctions π?', null, null)
+---------+
| success |
+---------+
| true |
+---------+
2. Send email with plain text file attached
select bigfunctions.eu.send_mail('contact@unytics.io', 'I love BigFunctions', 'Hey Paul, could you deploy more BigFunctions π?', 'report.csv', 'col1,col2\nval1,val2\nval3,val4')
select bigfunctions.us.send_mail('contact@unytics.io', 'I love BigFunctions', 'Hey Paul, could you deploy more BigFunctions π?', 'report.csv', 'col1,col2\nval1,val2\nval3,val4')
select bigfunctions.europe_west1.send_mail('contact@unytics.io', 'I love BigFunctions', 'Hey Paul, could you deploy more BigFunctions π?', 'report.csv', 'col1,col2\nval1,val2\nval3,val4')
+---------+
| success |
+---------+
| true |
+---------+
3. Send email with excel file attached
select bigfunctions.eu.send_mail('contact@unytics.io', 'I love BigFunctions', 'Hey Paul, could you deploy more BigFunctions π?', 'report.xlsx', (select eu.json2excel('[{"col1": "val1", "col2": "val2"}, {"col1": "val3", "col2": "val4"}]')))
select bigfunctions.us.send_mail('contact@unytics.io', 'I love BigFunctions', 'Hey Paul, could you deploy more BigFunctions π?', 'report.xlsx', (select us.json2excel('[{"col1": "val1", "col2": "val2"}, {"col1": "val3", "col2": "val4"}]')))
select bigfunctions.europe_west1.send_mail('contact@unytics.io', 'I love BigFunctions', 'Hey Paul, could you deploy more BigFunctions π?', 'report.xlsx', (select europe_west1.json2excel('[{"col1": "val1", "col2": "val2"}, {"col1": "val3", "col2": "val4"}]')))
+---------+
| success |
+---------+
| true |
+---------+