KNOWLEDGE BASE

Tabcmd for Generating a PDF of a Tableau View and Emailing


Published: 03 Apr 2017
Last Modified Date: 27 Oct 2017

Question

How to use tabcmd to generate a PDF file of a Tableau view and email it.

Environment

  • Tableau Server 9.3.12
  • Windows 64-bit

Answer

To generate a PDF, type the following command:

tabcmd get "<url-of-view>.pdf" -f "<filename>.pdf"
Replace <url-of-view> with the view's URL path after it has been published.

For example, the tabcmd command may look like this:

tabcmd get "/views/Wow/SummaryReports.pdf" -f "progressReport.pdf"

If the PDF generates successfully, tabcmd places the PDF file "progressReport.pdf" in the current working directory.

Notes regarding different versions of Tableau Server:

  • In versions of Tableau Server earlier than 9.0, ensure that you append <url-of-view> with ".pdf", as in the example above.
  • In Tableau Server 9.0 and later, you do not have to include the filename extension with the <url-of-view> value for PDF files; the command infers that you want a PDF file from the name you provide in the -f parameter.
  • Replace <filename> with the name you want to give to the generated PDF file.
  • For Tableau Server 8.1 through 8.3, ensure that you do not include the hash tag (#) and number at the end of the URL. For Tableau Server 9.0 and later, do not include ":iid=<n>."

Use tabcmd to send email messages with attachments

This example uses email shareware called febootimail, which allows full control over aspects of e-mail generation. (See Related Links below.)

This example sends the PDF progress report you generated as an e-mail attachment.

tabcmd login -s http://tableauserver:80 -u admin -p admin

tabcmd get "/views/Wow/SummaryReports.pdf" -f "progressReport.pdf"

febootimail.exe -SMTP yourSMTPhost.yourcompany.com -TO "recipient1@yourcompany.com; recipient2@yourcompany.com;recipient3@yourcompany.com" -FROM sender@yourcompany.com -SUBJECT "Generated Tableau View - Tableau Server Automated Alert System (TSAAS)" -ATTACH " C:\Program Files\Tableau\Tableau Command Line\progressReport.pdf" -BODY " this is the text of the body"

Notes regarding different versions of Tableau Server:

  • For Tableau Server 9.0 and later, do not include ":iid=<n>."
  • For Tableau Server 8.1 through 8.3, ensure that you do not include the hash tag (#) and number at the end of the URL.

Use tabcmd to send formatted email with embedded images

Tabcmd can generate PNG files, and febootimail can send HTML e-mail. The HTML file must be in the same directory as febootimail.

This example sends a PNG image of the progress report view you generated as an e-mail attachment.

tabcmd login -s http://tableauserver:80 -u admin -p admin

tabcmd get "/views/Wow/SummaryReports.png" -f "progressReport.png"

febootimail.exe -SMTP yourSMTPhost.yourcompany.com -TO "recipient1@yourcompany.com; recipient2@yourcompany.com;recipient3@yourcompany.com" -FROM sender@yourcompany.com -SUBJECT "Generated Tableau View - Tableau Server Automated Alert System (TSAAS)" - -HTMLFILE "emailbody.html"
 

Notice that the BODY tag has been replaced by an HTMLFILE tag. Because tabcmd can auto-generate a PNG image, you can reference that image in the body of an HTML email template as seen below:

<html>

<head><title>Email Alert</title></head>

<body><img src="progressReport.png"></body>

</html>

Notes regarding different versions of Tableau Server:

  • Tableau Server 9.0 and later, do not include ":iid=<n>."
  • For Tableau Server 8.1 through 8.3, ensure that you do not include the hash tag (#) and number at the end of the URL.

Additional Information

If you install febootimail and review its help files, you will note the following:

  • Instead of typing the e-mail addresses of recipients using the TO tag, you can refer to a file.
  • Instead of typing the e-mail body using the BODY tag, you can specify an HTMLFILE tag.
  • You can attach multiple files.

These features provide control over the Tableau generation and e-mail process. Many other applications and scripting languages also have this type of support.

  • While the tabcmd by itself cannot send email messages, if you are using Tableau Server 8.0 and later, you can configure email alerts if there is a system failure or subscriptions that allow users to subscribe to their favorite views. For more information about these features, refer to the Email Alerts/Subscriptions topic in the Server Online Help.
  • Febooti Commandline Email: http://www.febooti.com/products/command-line-email/
Did this article resolve the issue?