--- title: "Writing to emails (Email.Send)" slug: "writing-to-emails-emailsend" updated: 2026-04-30T10:28:14Z published: 2026-04-30T10:28:14Z canonical: "support.lusid.com/writing-to-emails-emailsend" --- > ## Documentation Index > Fetch the complete documentation index at: https://support.lusid.com/llms.txt > Use this file to discover all available pages before exploring further. # Writing to emails (Email.Send) You can request an `Email.Send` provider from FINBOURNE and use it to send the results of your [Luminesce queries](/v1/docs/luminesce-and-lumipy) in emails via SMTP. You can use this provider in conjunction with other providers to write the results of a query to an email and send this to a custom list of recipients. [See example 2.](/v1/docs/writing-to-emails-emailsend#example-2-sending-valuation-results-as-an-email) ## Setup > [!NOTE] > Prerequisites > > Before getting started, ensure you have an SMTP server account and its credentials. To use the `Email.Send` provider, you must supply your SMTP server account credentials to the [Configuration Store](/v1/docs/configuration-store). To do this: 1. Sign in to the [LUSID web app](https://www.lusid.com/app) using the credentials of a LUSID administrator. 2. From the top left menu, select **System Settings > Configuration Store**. ![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(145).png?sv=2026-02-06&spr=https&st=2026-11-04T01%3A47%3A12Z&se=2026-11-04T02%3A47%3A12Z&sr=c&sp=r&sig=wjM%2Fv9LZR%2FHmwBXB8vlSlcwc0h2LCFez3JaMV6cP%2BIM%3D) 3. Select the **Add configuration set** button. ![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(151).png?sv=2026-02-06&spr=https&st=2026-11-04T01%3A47%3A12Z&se=2026-11-04T02%3A47%3A12Z&sr=c&sp=r&sig=wjM%2Fv9LZR%2FHmwBXB8vlSlcwc0h2LCFez3JaMV6cP%2BIM%3D) 4. Set the **Scope** value to `Luminesce-Provider` and **Code** value to `Email`. 5. Provide the following **Key** and **Value** pairs to the configuration set: - `UserName`: Your SMTP server account email address. - `Password`: Your SMTP server account password. Note you may need to create an app-specific password in order for your credentials to work. - `ServerAddress`: Your SMTP server address. - `ServerPort`: We currently support `587`. - `Type`: We currently support `Smtp`. - `SecureSocketOptions`: We currently support `StartTls`. - `AddressFrom`: How your sender address should appear in emails, specified in the format `[<text>](<your-email-address>)`. ![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(153).png?sv=2026-02-06&spr=https&st=2026-11-04T01%3A47%3A12Z&se=2026-11-04T02%3A47%3A12Z&sr=c&sp=r&sig=wjM%2Fv9LZR%2FHmwBXB8vlSlcwc0h2LCFez3JaMV6cP%2BIM%3D) 6. Click **Save** to create the configuration set. ## Basic usage Once you have supplied your SMTP server account credentials to the Configuration Store, you can begin using the `Email.Send` provider. ```sql @data = select * from where ; @email = use Email.Send with @data --subject="" -- ------------ enduse; select * from @email ``` ## Input tables `Email.Send` takes in one or more input tables and outputs a table of data containing what was requested of SMTP and how it responded. It also sends an email with one or more attachments containing the input tables. [See examples.](/v1/docs/writing-to-emails-emailsend#examples) ## Options `Email.Send` has options that enable you to refine a query. An option takes the form `--<option>=<value>`, for example `--attachAs=Csv`. Note no spaces are allowed either side of the `=` operator. If an option takes a boolean value, then specifying that option (for example `--allowFailure`) sets it to True; omitting the option specifies False. Current options at article update time are listed in the table below. For the very latest information, run the following query using a [suitable tool](/v1/docs/what-tools-are-available-to-write-luminesce-queries) and examine the online help: ```sql @x = use Email.Send --help enduse; select * from @x ``` | Option | Value | Status | Information | | --- | --- | --- | --- | | `--subject` | String | Mandatory | The subject for the email. | | `--addressTo` | `<email-address>` or `[<name>](<email-address>)` | Optional | Email addresses to send the email to. | | `--addressCc` | Email addresses to CC into the email. | | `--addressBcc` | Email addresses to BCC into the email. | | `--topN` | Integer | When not attaching a table of data as a file, the maximum number of rows to show in any table. Defaults to 5. | | `--attachAs` | Any of the following: - `Csv` - `Excel` - `SqLite` - `Json` | Attaches tables of data as files of this type. | | `--attachAsOneFileName` | `<filename.type>` | When attaching more than one file, combines into one file with the filename you specify. | | `--allowFailure` | Boolean | When omitted, the query produces an error if the email can’t be sent. | | `--ignoreOnZeroRows` | Boolean | If specified, does not send an email if one or more tables are provided and all have no rows. | ## Examples ### Example 1: Sending an email with a CSV attachment In this example, we pass a table of data into the `Email.Send` provider and specify it should be attached as a CSV. ```sql @table_of_data = select 'this' as MyFirstColumn        union all        select 'that' as MySecondColumn; @email = use Email.Send with @table_of_data --addressTo="[J Smith](jane.smith@acme.com)" --attachAs=Csv --subject="Here are the results of your query" ------------ Hello, Please find the results of your query attached. enduse; select * from @email ``` The table of data returned by the query looks like this, showing us the SMTP request and how it responded: ![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(154).png?sv=2026-02-06&spr=https&st=2026-11-04T01%3A47%3A12Z&se=2026-11-04T02%3A47%3A12Z&sr=c&sp=r&sig=wjM%2Fv9LZR%2FHmwBXB8vlSlcwc0h2LCFez3JaMV6cP%2BIM%3D) The email recipient receives the following email, with a CSV file attached containing our table of data: ![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(155).png?sv=2026-02-06&spr=https&st=2026-11-04T01%3A47%3A12Z&se=2026-11-04T02%3A47%3A12Z&sr=c&sp=r&sig=wjM%2Fv9LZR%2FHmwBXB8vlSlcwc0h2LCFez3JaMV6cP%2BIM%3D) ### Example 2: Sending valuation results as an email In this example, we use [Lusid.Portfolio.Valuation](/v1/docs/lusidportfoliovaluation) to perform a valuation on a portfolio and pass the results into the `Email.Send` provider. We specify the results should be attached as an Excel file and sent to `jane.smith@acme.com`, as well as CCing `joe.bloggs@acme.com`. ```sql @table_of_data = select * from Lusid.Portfolio.Valuation  where Recipe = 'FBNUniversity/Module-4-1Recipe'    and PortfolioCode = 'Module-4-1'    and PortfolioScope = 'FBNUniversity'    and EffectiveAt = #2022-03-07#; @email = use Email.Send with @table_of_data --addressTo="[J Smith](jane.smith@acme.com)" --addressCc="[J Bloggs](joe.bloggs@acme.com)" --attachAs=Excel --subject="Valuation results" ------------ Hello, Here are the results of your valuation. enduse; select * from @email ``` The email recipients receive the following email, with an Excel file attached containing our table of data: ![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(161).png?sv=2026-02-06&spr=https&st=2026-11-04T01%3A47%3A12Z&se=2026-11-04T02%3A47%3A12Z&sr=c&sp=r&sig=wjM%2Fv9LZR%2FHmwBXB8vlSlcwc0h2LCFez3JaMV6cP%2BIM%3D) ### Example 3: Sending an email with many attachments In this example, we pass two different tables of data into `Email.Send` and specify they should be attached as CSV files. We also use Markdown to explain the attachments in the email body. ```sql @valuation_data = select * from Lusid.Portfolio.Valuation  where Recipe = 'FBNUniversity/Module-4-1Recipe'    and PortfolioCode = 'Module-4-1'    and PortfolioScope = 'FBNUniversity'    and EffectiveAt = #2022-03-07#; @instrument_data = select * from Lusid.Instrument.Equity limit 10; @email = use Email.Send with @valuation_data, @instrument_data --addressTo="[J Smith](jane.smith@acme.com)" --attachAs=Csv --subject="Some results with more than one attachment" ------------ Hello, Please find the following attached: - The results of your valuation - The first ten equity instruments enduse; select * from @email ``` The email recipient receives the following email, with formatted Markdown in the email body and two CSV files attached containing our tables of data: ![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(169).png?sv=2026-02-06&spr=https&st=2026-11-04T01%3A47%3A12Z&se=2026-11-04T02%3A47%3A12Z&sr=c&sp=r&sig=wjM%2Fv9LZR%2FHmwBXB8vlSlcwc0h2LCFez3JaMV6cP%2BIM%3D) ### Example 4: Using Email.Send in a custom view In this example, we create a custom view using [Sys.Admin.SetupView](/v1/docs/creating-custom-views-sysadminsetupview) that takes in a [LUID](/v1/docs/what-is-a-lusid-instrument-id-or-luid) and an email recipient, retrieves data about the instrument, and then sends the results in an email. To prevent issues occurring due to `----` being required by both the `Sys.Admin.SetupView` and `Email.Send` providers, we instead use `@@separator = select '--' || '--' as x;` to pass in `----` to the `Email.Send` provider as `{@@separator}`. ```sql @x = use Sys.Admin.SetupView --provider=Views.EmailInstruments --parameters LUID,Text,LUID_00003D5T,true recipient,Text,[J Smith](jane.smith@acme.com),true ---- @data = select * from Lusid.Instrument where LusidInstrumentId = #PARAMETERVALUE(LUID); @@recipient = select #PARAMETERVALUE(recipient); @@separator = select '--' || '--' as x; @email = use Email.Send with @@separator, @data, @@recipient --addressTo="{@@recipient}" --attachAs=Csv --subject="Instruments from your view" {@@separator} Hello, Here are your results. enduse; select * from @email where Ok = true; enduse; select * from @x ``` When the new custom view `Views.EmailInstruments` is called, the email recipient receives the following email which contains the table of data attached as a CSV file: ![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(170).png?sv=2026-02-06&spr=https&st=2026-11-04T01%3A47%3A12Z&se=2026-11-04T02%3A47%3A12Z&sr=c&sp=r&sig=wjM%2Fv9LZR%2FHmwBXB8vlSlcwc0h2LCFez3JaMV6cP%2BIM%3D)