In this article I will explain how to generate PDF file/document
of a Tableau view, send this document as an attachment in email and how to
automate this procedure.
We can achieve this task using Tableau Server command line tool (tabcmd)
and third party email sending utilities.
Generate pdf file of Tableau View
- Go to Tableau Server
machine, open Command Prompt with administrative rights
- On Command Prompt, navigate to Tableau Server bin directory by typing the below command
cd C:\Program Files\Tableau\Tableau Server\<version>\bin
(or)
cd C:\ Program Files (x86)\Tableau\Tableau Server\<version>\bin
- Login to Tableau Server using below command
tabcmd login -s http ://<host>:<port> -u
<username> -p <password>
You can see some status message after running the above command.
- Now, type the below command to generate pdf file of Tableau view
tabcmd get "<url-of-view>" -f
"<filename>.pdf"
ex: tabcmd get
"/views/Dashboard-SalesProfits/Dashboard2" -f "C:\tmp_Folder\dashboard22.pdf"
pdf file will be generated and saved in C:\tmp_Folder (create this folder
before executing the above command).
Email
the generated pdf file as an attachment
First of all, download and install “febootimail” command line email
sending utility from http://www.febooti.com/
website.
- On Command Prompt,
navigate to “feebootimail” installation path
cd C:\Program Files (x86)\Febooti Command line email
febootimail -SMTP <your-mail-smtp> -PORT
<port-number> -TO "<email-1; email-2>" -FROM
<email-from-id> -SUBJECT "email subject line" -ATTACH
"<path-of-generated-pdf-file>" -BODY "email message"
ex: febootimail -SMTP mail.infinysis.com -PORT 25 -TO
"naga.allaboutbi@gmail.com" -FROM naga.k@infinysis.com -SUBJECT
"Tableau View - PDF format " -HTML -TEXT "Hi, <br/> Please
find the attached file for Tableau view in pdf format. <br /><br />
http://localhost:8000/ " -Attach "c:\tmp_Folder\dashboard22.pdf"
-AUTH LOGIN -USER naga.k@infinysis.com -PASS *******
Here is the snapshot of the email message
Additionally, you can put the entire script in a BATCH file
and schedule it using windows task scheduler.
Find the complete script below.
Happy coding!!!