send_mail_with_excel¶
send_mail_with_excel(to, subject, content, excel_filename, table_or_view_or_query)
Description¶
Sends an email with table_or_view_or_query
data attached as excel file
(only the first 1000 rows will be copied to the excel file)
This function calls
json2excel
andsend_mail
functions.
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 |
filename with extension such as report.xlsx |
table_or_view_or_query |
A fully qualified table or view you have permission to read or a sql query starting with select |
Usage¶
Call or Deploy send_mail_with_excel
?
Call send_mail_with_excel
directly
The easiest way to use bigfunctions
send_mail_with_excel
function is deployed in 39 public datasets for all of the 39 BigQuery regions.- It can be called by anyone. Just copy / paste examples below in your BigQuery console. It just works!
- (You need to use the dataset in the same region as your datasets otherwise you may have a function not found error)
Public BigFunctions Datasets
Region | Dataset |
---|---|
eu |
bigfunctions.eu |
us |
bigfunctions.us |
europe-west1 |
bigfunctions.europe_west1 |
asia-east1 |
bigfunctions.asia_east1 |
... | ... |
Deploy send_mail_with_excel
in your project
Why deploy?
- You may prefer to deploy
send_mail_with_excel
in your own project to build and manage your own catalog of functions. - This is particularly useful if you want to create private functions (for example calling your internal APIs).
- Get started by reading the framework page
Deployment
send_mail_with_excel
function can be deployed with:
pip install bigfunctions
bigfun get send_mail_with_excel
bigfun deploy send_mail_with_excel
Examples¶
call bigfunctions.eu.send_mail_with_excel(
'contact@unytics.io',
'Financial Report',
'''
# Monthly Report from BigQuery
## KPIs
- **MRR**: 32,343 USD
- **Churn**: 4.2 %
- **Subscriptions**: +3452
''',
'report.xlsx',
'bigfunctions.eu.sales');
call bigfunctions.us.send_mail_with_excel(
'contact@unytics.io',
'Financial Report',
'''
# Monthly Report from BigQuery
## KPIs
- **MRR**: 32,343 USD
- **Churn**: 4.2 %
- **Subscriptions**: +3452
''',
'report.xlsx',
'bigfunctions.us.sales');
call bigfunctions.europe_west1.send_mail_with_excel(
'contact@unytics.io',
'Financial Report',
'''
# Monthly Report from BigQuery
## KPIs
- **MRR**: 32,343 USD
- **Churn**: 4.2 %
- **Subscriptions**: +3452
''',
'report.xlsx',
'bigfunctions.europe_west1.sales');
Use cases¶
A marketing analyst wants to send a weekly performance report to their team. They have a BigQuery table called marketing.weekly_performance
that contains data on ad spend, impressions, clicks, conversions, and other relevant metrics.
Use Case:
Using the send_mail_with_excel
function, the analyst can automate the process of:
- Querying the BigQuery table: The
table_or_view_or_query
parameter can be set tomarketing.weekly_performance
. - Converting the results to an Excel file: The function automatically handles the conversion of the query results into an Excel file named, for example,
weekly_report.xlsx
. - Emailing the report: The analyst can specify recipients (
to
), subject line (subject
), and email body content (content
). The Excel file will be attached to the email.
Example BigQuery SQL:
call bigfunctions.<your-region>.send_mail_with_excel(
'marketing_team@company.com',
'Weekly Marketing Performance Report',
'''
Hello Team,
Please find attached the weekly marketing performance report.
Regards,
Marketing Analyst
''',
'weekly_report.xlsx',
'marketing.weekly_performance'
);
Benefits:
- Automation: Eliminates the manual steps of querying, exporting to Excel, and emailing.
- Time-saving: Frees up the analyst's time for more strategic tasks.
- Consistency: Ensures that the report is delivered on time and in a consistent format.
- Collaboration: Makes it easy to share the report with the entire marketing team.
Other potential use cases:
- Sales reporting: Sending daily or weekly sales figures to the sales team.
- Financial reporting: Distributing monthly financial statements to stakeholders.
- Customer support reporting: Sharing weekly customer support metrics with the customer support team.
- Automated alerts: Triggering an email with relevant data when certain thresholds are met (e.g., a sudden drop in website traffic). This would likely require integrating the function within a scheduled query or other automated workflow.
Need help or Found a bug?
Get help using send_mail_with_excel
The community can help! Engage the conversation on Slack
We also provide professional suppport.
Report a bug about send_mail_with_excel
If the function does not work as expected, please
- report a bug so that it can be improved.
- or open the discussion with the community on Slack.
We also provide professional suppport.