Davis Weatherlink Email Using sendEmail

Description
This document describes a method of generating and emailing weather summaries on a schedule using Davis Weatherlink, sendEmail and Windows scheduler. Tobaccovilleweather.com uses this technique to email weather reports to WXII meteorologists four times a day 45 minutes before air time.

Operation
Weatherlink processes a custom template file which contains the desired formatting and tags for building the message body. The output of the template is a text file containing the message body. At the scheduled time Windows scheduler runs a batch file which invokes sendEmail. All necessary information to email the message is passed to sendEmail via the command line. SendEmail builds the email message and adds any attachments. When the message is ready sendEmail contacts the specified SMTP host and sends the message.

You Will Need

  1. Davis Weatherlink 5.6, 5.7 or 5.9
  2. Weatherlink template for generating message body
  3. sendEmail PERL script or executable
  4. A batch file that contains the sendEmail parameters
  5. PERL interpreter (optional)
  6. A basic understanding of Weatherlink templates and profiles

The Weatherlink Template
Here is an example of the Weatherlink template for the message body. You can build your own or modify this one. Beware of HTML editors. Weatherlink tags look like HTML comments. Many HTML editors can't deal with inline comments and will trash the template. A simple text editor is probably the best choice for creating and editing Weatherlink templates.
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
 <title>Weather Report for Tobaccoville</title>
 </head>
<body>
 <p><b><font size="4">Weather Report for Tobaccoville, NC</font></b><br>
 From: Tom, WB4SNA <br>
 Generated: <!--date--> <!--time-->
</p>
 <p>
 <a href="http://tobaccovilleweather.com">http://tobaccovilleweather.com</a></p>
 <p>&nbsp;<table border="1" width="600" id="table1">
 <tr>
 <td align="center" width="300"><b><font size="4">Weather Summary</font></b></td>
 <td align="left" valign="top"><b>Station Data</b><br>
 <font size="2">Davis Vantage Pro2<br>
 Elevation: <!--stationElevation--><br>
 Latitude: <!--StationLatitude--><br>
 Longitude: <!--StationLongitude--></font><br>
 </td>
 </tr>
 <tr>
 <td align="left" valign="top" width="300">
 <b>Temperature<br>
 </b><font size="2">Current: <!--outsideTemp--> <!--tempUnit--><br>
 Today's High: <!--hiOutsideTemp--> <!--tempUnit--> at <!--hiOutsideTempTime--><br>
 Today's Low: <!--lowOutsideTemp--> <!--tempUnit--> at <!--lowOutsideTempTime-->
 </font><br>
 </td>
 <td align="left" valign="top"><b>Dew Point</b><br>
 <font size="2">Current: <!--outsideDewPt--> <!--tempUnit--><br>
 Today's	High: <!--hiDewpoint--> <!--tempUnit--> at <!--hiDewpointTime--><br>
 Today's	Low: <!--lowDewpoint--> <!--tempUnit--> at <!--lowDewpointTime--></font><br>
 </td>
 </tr>
 <tr>
 <td align="left" valign="top" width="300"><b>Humidity<br>
 </b><font size="2">Current: <!--outsideHumidity--> <!--humUnit--><br>
 Today's High: <!--hiHumidity--> <!--humUnit--> at <!--hiHumTime--><br>
 Today's	Low: <!--lowHumidity--> <!--humUnit--> at <!--lowHumTime--></font><br>
 </td>
 <td align="left" valign="top"><b>Barometric Pressure (SL)</b><br>
 <font size="2">Current: <!--barometer--> <!--barUnit--><br>
 Trend: <!--barTrend--></font><br>
 </td>
 </tr>
 <tr>
 <td align="left" valign="top" width="300"><b>Rain</b><br>
 <font size="2">Current Rain Rate: <!--rainRate--><br>
 Today's High Rain Rate: <!--hiRainRate--> <!--rateUnit--> at <!--hiRainRateTime--><br>
 Today's Rain Total: <!--dailyRain--> <!--rainUnit--><br>
 Storm Rain Total: <!--stormRain--> <!--rainUnit--><br>
 Monthly Rain Total: <!--monthlyRain--> <!--rainUnit--><br>
 Yearly Rain Total: <!--totalRain--> <!--rainUnit--></font><br>
 </td>
 <td align="left" valign="top"><b>Wind</b><br>
 <font size="2">Current Speed: <!--windSpeed--> <!--windUnit--> from the <!--windDirection--><br>
 Gust: <!--windHigh10--> <!--windUnit--><br>
 10 Minute Average: <!--wind10Avg--> <!--windUnit--><br>
 Today's High: <!--hiWindSpeed--> <!--windUnit--> at <!--hiWindSpeedTime-->
 </font></td>
 </tr>
 </table>
 <p><u><b>Weather Cam image attached.</b></u>
 </body>
</html>

sendEmail
The sendEmail author now provides a sendEmail executable for Windows. This makes it unnecessary to install the PERL interpreter. The distribution containing the Windows executable is here: sendEmail Distribution With Windows Executable. The sendEmail PERL script is also included in the distribution if you want to see what is inside.

sendEmail Batch File
"Drive:\FolderWithExecutable\sendEmail.exe" -f "Your Name <your@email.address>" -t "Recipients Name <recipients@email.address>" -s smtp.server.your.domain -o message-file="Drive:\PathToBodyText\BodyTextFileName" -u "EmailSubject" -a "Drive:\PathToAttachment\AttachmentFileName" -l "Drive:\PathForLogFile\LogFileName.log" -v

PERL Interpreter
ActivePerl for Windows can be found here: Active State PERL. Get the Microsoft MSI version. Installation should be straightforward and trouble free if the installation defaults are used. Not needed with sendEmail Windows executable.


Set-up

  1. Make the Weatherlink Template
    • Copy the template above and paste it into your favorite text editor.
    • Modify the template to suit your needs.
    • Save the new file with a ".htx" extension.
    • Copy the template to the Weatherlink template folder.
    • Make a new profile or select an existing one.
    • Add the new template to the selected profile.
    • Enter a local path and enable the local transfer so the file will be created on the local disk.
  2. Install sendEmail
    • Unzip the sendEmail distribution into a new folder.
    • Note the location of this folder. It will be needed when building the batch file.
  3. Make the sendEmail Batch File
    • Copy the sample batch file above and paste it into your favorite text editor. The command is a single line and must not contain any extra line breaks (cr/lf). For ease of editing turn on the editor's word wrap feature or add extra breaks but be sure to remove them when finished.
      • -f This is the "FROM" field. Your name and email address goes here.
      • -t This is the "TO" field. The recipient email address goes here. Multiple recipients are separated by semicolons (;)
      • -s SMTP server host name
      • -o Path to and name of file containing message body text. This points to the text file being generated by Weatherlink.
      • -u Email subject line
      • -a Path to and file name of attachment (optional)
      • -l Path to and file name of log file (optional)
      • -v verbose logging. This is good for debugging but it makes huge log files.
    • Save the file with a ".bat" extension in the sendEmail folder.
  4. Test the System
    • Make a copy of the batch file just created.
    • Edit the copy so the "FROM" and "TO" fields are the same. This will send the message back to the sender.
    • Make a dummy body text file.
    • Edit the test batch file so it points to the dummy body text file.
    • Open a command window. Start>Run>type CMD>OK. You should get a command window with a DOS prompt.
    • If sendEmail is on a different drive type in the drive letter followed by a colon (:) and press [enter]
    • Change to the folder containing sendEmail. Type CD \Full Path to sendEmail. If sendEmail is in a folder called sendEmail under root you would type "CD \sendEmail" (without the quotes) and press [enter]. The command prompt should display the path you entered.
    • At the command prompt type the name of your test batch file and hit [enter].
    • SentEmail should run and scroll some information in the command window. Any errors should be displayed in the command window.
    • Check your inbox for the message. The message should contain the text from the dummy body text file.
  5. Configuring Windows scheduler
    • Open Windows "Control Panel".
    • Open "Scheduled Tasks".
    • Open "Add Scheduled Task". The "Scheduled Task Wizard" should start.
    • Click "Next".
    • Click the "Browse" button.
    • Browse to the sendEmail batch file, select it and click "Open". The next wizard screen should appear.
    • Type a unique name like "sendEmail1" for the schedule if you plan to have more than one scheduled send time.
    • Click the "Daily" radio button and click "Next"
    • Set the "Start Time" to the desired email send time.
    • Select which days you want the task to run and click "Next".
    • Enter the user name and password of the user the scheduler will use to start the task and click "Next".
    • Check the "Open advanced properties" check box and click "Finish"
    • When the task properties window opens select the "Settings" tab.
    • Check the "Stop task" radio button and set the timeout to 1 hour then click "OK".

This site automatically updated by Thread Upload FTP Client

Tobaccoville Weather Home

Site contents © tobaccovilleweather.com  
All rights reserved. Unauthorized duplication or distribution is prohibited.
Never base important decisions on this or any other unofficial weather information.