Sending Deephaven Data by Email

You can easily send an HTML representation of a Deephaven table or report by email to one or more recipients using methods in the TableTools.html class.

The syntax follows:

html(tableName)
.sendHTMLEmail("smtpSender","smtpReceiver","emailSubject",tableName)

Example

#TODO SMTPMailer
from deephaven import *
SMTPMailer = jpy.get_type("com.fishlib.util.SMTPMailer")

tableAsHtml = ttools.html(TableName)  # write the table to an html string

SMTPMailer().sendHTMLEmail(
    "[email protected]",
    "[email protected]",
    "Report from Deephaven",
    tableAsHtml
)
import com.fishlib.util.SMTPMailer
tableAsHtml = html(TableName)
new SMTPMailer().sendHTMLEmail(
   "[email protected]",
   "[email protected]",
   "Report from Deephaven",
   tableAsHtml
)

The first line of the query imports the SMTPMailer class. The second line of the query creates an HTML representation of a table open in your console (TableName).

The third line of the query creates a new instance of the SMTP mailer.  Within the sendHTMLEmail() function, the query first specifies the sender and desired recipient of the email. If you would like to send the message to more than one person, create an array: ["[email protected]", "[email protected]"]. Then, the query creates a subject line for the email (here, "Report from Deephaven") and identifies the HTML object to send in the body of the message.

Note: The host on which workers trigger the send mail query should be able to talk to the outgoing SMTP host or SMTP relay on your network.

To preview what the HTML will look like in the message in the log panel of your console, type:

println tableAsHtml

Disable/Enable Email feature

It is also possible to disable sending emails by setting the following property:

smtp.sendEmail.disabled=true

This will cause the Deephaven email calls to not actually send emails.


Last Updated: 16 February 2021 18:06 -04:00 UTC    Deephaven v.1.20200928  (See other versions)

Deephaven Documentation     Copyright 2016-2020  Deephaven Data Labs, LLC     All Rights Reserved