<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Sending Email via VBScript and batch script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Sending-Email-via-VBScript-and-batch-script/m-p/297728#M710928</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Take a look to this thread:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.qlik.com/message/116035#116035"&gt;http://community.qlik.com/message/116035#116035&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 Jan 2013 13:07:07 GMT</pubDate>
    <dc:creator>chematos</dc:creator>
    <dc:date>2013-01-07T13:07:07Z</dc:date>
    <item>
      <title>Sending Email via VBScript and batch script</title>
      <link>https://community.qlik.com/t5/QlikView/Sending-Email-via-VBScript-and-batch-script/m-p/297724#M710924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to figure out if it is possible to do a reload of a qvw file from a batch script and then, using a module on the report, output a straight table to a file and send it via email.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've managed to create the batch script to reload the report and export the straight table no problem. The issue is the emailing part and trying to get it to work in combination with the batch script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For some reason, if I reload the report with it open (just from the reload button) it works and the module sends the email. If I close the report and run the batch script then the report reloads (I see the progress pop-up box) but I don't get the email and the command prompt stays open. Below is the VBScript I'm using (by the way, I've been chopping it from various different web sites and posts here so may be a mess!):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;sub testy()&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;dim theDate&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;dim filename&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;if len(CStr(Month(Date()))) = 1 then&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; theDate = CStr(Day(Date())) &amp;amp; "0" &amp;amp; CStr(Month(Date())) &amp;amp; CStr(Year(Date()))&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;else&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; theDate = CStr(Day(Date())) &amp;amp; CStr(Month(Date())) &amp;amp; CStr(Year(Date()))&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;end if&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;filename = "C:\Users\chris_johnson\Documents\Test " &amp;amp;theDate&amp;amp; ".xls"&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;call ExportToExcel(filename)&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;end sub&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;sub ExportToExcel (filename)&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;dim o&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;'dim theDate&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;'dim filename&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;Set o = ActiveDocument.GetSheetObject("LA01")&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;'theDate = CStr(Date())&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;'filename = "C:\Users\chris_johnson\Documents\Test " &amp;amp;theDate&amp;amp; ".xls"&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;o.ExportBiff filename&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;set o = Nothing&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;call SendEmail(filename)&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;end sub&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;sub SendEmail(attachment)&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN&gt;varTo = "&lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:myemail@company.com"&gt;myemail@company.com&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;varSubject = "Report"&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;varTextBody = "Please find report attached"&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;varAttachment = attachment&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;Dim ObjSendMail&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;Set ObjSendMail = CreateObject("CDO.Message")&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;'This section provides the configuration information for the remote SMTP server.&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN&gt;ObjSendMail.Configuration.Fields.Item ("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://schemas.microsoft.com/cdo/configuration/sendusing"&gt;http://schemas.microsoft.com/cdo/configuration/sendusing&lt;/A&gt;&lt;SPAN&gt;") = 2 'Send the message using the network (SMTP over the network).&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN&gt;ObjSendMail.Configuration.Fields.Item ("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://schemas.microsoft.com/cdo/configuration/smtpserver"&gt;http://schemas.microsoft.com/cdo/configuration/smtpserver&lt;/A&gt;&lt;SPAN&gt;") = "smtpserv"&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;ObjSendMail.Configuration.Fields.Update&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;ObjSendMail.To = varTo&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;ObjSendMail.Subject = varSubject&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN&gt;ObjSendMail.From = "&lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:myemail@company.com"&gt;myemail@company.com&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;' we are sending a text email.. simply switch the comments around to send an html email instead&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;'ObjSendMail.HTMLBody = "this is the body"&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;ObjSendMail.TextBody = varTextBody&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;ObjSendMail.AddAttachment varAttachment&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;ObjSendMail.Send&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;Set ObjSendMail = Nothing&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;end sub&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;Can someone help me with trying to understand if (1) this is the right way to go about this and (2) how to change this script in order to get it to work with emailing from batch script.&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;I've had half a thought that maybe I should remove the emailing part from the VBScript and possibly put it into the batch script.&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;Thanks,&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;Chris&lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2011 10:54:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sending-Email-via-VBScript-and-batch-script/m-p/297724#M710924</guid>
      <dc:creator>chris_johnson</dc:creator>
      <dc:date>2011-05-13T10:54:17Z</dc:date>
    </item>
    <item>
      <title>Sending Email via VBScript and batch script</title>
      <link>https://community.qlik.com/t5/QlikView/Sending-Email-via-VBScript-and-batch-script/m-p/297725#M710925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, so I've ripped a load of the VBScript out to create the email and put it in it's own little .vbs file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All that's left is a call to the function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dim wscript&lt;/P&gt;&lt;P&gt;dim sendmail&lt;/P&gt;&lt;P&gt;set sendmail = "C:\Users\chris_johnson\Documents\SendMail.vbs"&lt;/P&gt;&lt;P&gt;set wscript = CreateObject("WScript.Shell")&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;wscript sendmail &lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:myemail@company.com"&gt;myemail@company.com&lt;/A&gt;&lt;SPAN&gt; """New Report""" """Hope this works""" filename&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately, when I 'Check' the code using the module editor it tells me that it expected the end of the statement after the sendmail. I'm not sure what it is that I need to change...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2011 12:41:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sending-Email-via-VBScript-and-batch-script/m-p/297725#M710925</guid>
      <dc:creator>chris_johnson</dc:creator>
      <dc:date>2011-05-13T12:41:51Z</dc:date>
    </item>
    <item>
      <title>Sending Email via VBScript and batch script</title>
      <link>https://community.qlik.com/t5/QlikView/Sending-Email-via-VBScript-and-batch-script/m-p/297726#M710926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Slightly further along again. I have changed things around and managed to successfully 'Check' the VBScript:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dim wscript&lt;/P&gt;&lt;P&gt;dim sendmail&lt;/P&gt;&lt;P&gt;set sendmail = "C:\Users\chris_johnson\Documents\SendMail.vbs"&lt;/P&gt;&lt;P&gt;set wscript = CreateObject("WScript.Shell")&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;wscript sendmail &amp;amp;" "&amp;amp; "&lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:johnson@uk.belfor.com"&gt;johnson@uk.belfor.com&lt;/A&gt;&lt;SPAN&gt;" &amp;amp;" "&amp;amp; """New Report""" &amp;amp;" "&amp;amp; """Hope this works""" &amp;amp;" "&amp;amp; filename&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I click the 'Test' button however, it errors on the line 'set wscript = "C:\Users...'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error it gives me is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Object required: '[string: "C:\Users\chris_johns"]'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2011 13:12:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sending-Email-via-VBScript-and-batch-script/m-p/297726#M710926</guid>
      <dc:creator>chris_johnson</dc:creator>
      <dc:date>2011-05-13T13:12:13Z</dc:date>
    </item>
    <item>
      <title>Sending Email via VBScript and batch script</title>
      <link>https://community.qlik.com/t5/QlikView/Sending-Email-via-VBScript-and-batch-script/m-p/297727#M710927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah, so if I change it to (removed one of the 'set' commands):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dim wscript&lt;/P&gt;&lt;P&gt;dim sendmail&lt;/P&gt;&lt;P&gt;sendmail = "C:\Users\chris_johnson\Documents\SendMail.vbs"&lt;/P&gt;&lt;P&gt;set wscript = CreateObject("WScript.Shell")&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;wscript sendmail &amp;amp;" "&amp;amp; "&lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:johnson@uk.belfor.com"&gt;johnson@uk.belfor.com&lt;/A&gt;&lt;SPAN&gt;" &amp;amp;" "&amp;amp; """New Report""" &amp;amp;" "&amp;amp; """Hope this works""" &amp;amp;" "&amp;amp; filename&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I get:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Object doesn't support this property or method: 'wscript'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hmph&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2011 13:15:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sending-Email-via-VBScript-and-batch-script/m-p/297727#M710927</guid>
      <dc:creator>chris_johnson</dc:creator>
      <dc:date>2011-05-13T13:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: Sending Email via VBScript and batch script</title>
      <link>https://community.qlik.com/t5/QlikView/Sending-Email-via-VBScript-and-batch-script/m-p/297728#M710928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Take a look to this thread:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.qlik.com/message/116035#116035"&gt;http://community.qlik.com/message/116035#116035&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Jan 2013 13:07:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sending-Email-via-VBScript-and-batch-script/m-p/297728#M710928</guid>
      <dc:creator>chematos</dc:creator>
      <dc:date>2013-01-07T13:07:07Z</dc:date>
    </item>
  </channel>
</rss>

