Skip to content

bigfunctions > send_mail_with_excel

send_mail_with_excel

Call or Deploy send_mail_with_excel ?

✅ You can call this send_mail_with_excel bigfunction directly from your Google Cloud Project (no install required).

  • This send_mail_with_excel function is deployed in bigfunctions GCP project in 39 datasets for all of the 39 BigQuery regions. You need to use the dataset in the same region as your datasets (otherwise you may have a function not found error).
  • Function is public, so it can be called by anyone. Just copy / paste examples below in your BigQuery console. It just works!
  • You may prefer to deploy the BigFunction in your own project if you want 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). Discover the framework

Public BigFunctions Datasets:

Region Dataset
eu bigfunctions.eu
us bigfunctions.us
europe-west1 bigfunctions.europe_west1
asia-east1 bigfunctions.asia_east1
... ...

Description

Signature

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 and send_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

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');

screenshot

Need help using send_mail_with_excel?

The community can help! Engage the conversation on Slack

For professional suppport, don't hesitate to chat with us.

Found a bug using 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.

For professional suppport, don't hesitate to chat with us.

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:

  1. Querying the BigQuery table: The table_or_view_or_query parameter can be set to marketing.weekly_performance.
  2. 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.
  3. 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.

Spread the word

BigFunctions is fully open-source. Help make it a success by spreading the word!

Share on Add a on