<?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: Email a report through Macro in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Email-a-report-through-Macro/m-p/246011#M93757</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sam,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can get the customer name via a variable and then assign its content to the subject&lt;/P&gt;&lt;P&gt; oMailDoc.Subject = "Sales Report for " &amp;amp; ActiveDocument.Variables("SelectedCustomer").GetContent.String&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The variable can be defined in Qlikview document properties: &lt;/P&gt;&lt;P&gt;only(CustomerName)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Masha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 03 Mar 2012 13:24:20 GMT</pubDate>
    <dc:creator>masha-ecraft</dc:creator>
    <dc:date>2012-03-03T13:24:20Z</dc:date>
    <item>
      <title>Email a report through Macro</title>
      <link>https://community.qlik.com/t5/QlikView/Email-a-report-through-Macro/m-p/246010#M93756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've been back and forth through previous posts and trawled the internet for VB Script guidance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I therefore throw myself on your mercy!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want a user to select a customer from a drop down list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then they need to press a button (run a macro) to generate an email to send to the relevant Sales Representative.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want the email address to come from a table in QV and the subject to read " Sales Report for " &amp;amp; CustomerName&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Macro code is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUB openMail&lt;/P&gt;&lt;P&gt;Set vOlApp = CreateObject("Outlook.Application")&lt;BR /&gt;Set vMessage = vOlApp.CreateItem(olMailItem)&lt;/P&gt;&lt;P&gt;'=====================================&lt;BR /&gt;'Setting the email recipient&lt;BR /&gt;vMessage.To = "&lt;A href="mailto:sam.sansome@rolwey.com"&gt;some.one@email.com&lt;/A&gt;"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;vMessage.Display&lt;/P&gt;&lt;P&gt;End SUB&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem comes with setting the Subject&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;When I set it as hard text (like the email as above) it works:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;vMessage.Subject = "Sales Report for"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;So does getting the document name from QV:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;vSubText = ActiveDocument.Name&lt;/P&gt;&lt;P&gt;vMessage.Subject = "Sales Report for " &amp;amp; vSubText&lt;/P&gt;&lt;P&gt;But obviously the DocumentName isn't the CustomerName I need&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I tried using the SheetName (set as a formula ='Sales Report for '&amp;amp;CustomerName):&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;vSubText = ActiveDocument.ActiveSheet.GetProperties.Name&lt;/P&gt;&lt;P&gt;vMessage.Subject = "Sales Report for " &amp;amp; vSubText&lt;/P&gt;&lt;P&gt;But this just gives me an email subject of "='Sales Report for '&amp;amp;CustomerName"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I've tried copying and pasting a Text Box (TX01 = CustomerName):&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;ActiveDocument.GetSheetObject("TX01").CopyTextToClipboard&lt;/P&gt;&lt;P&gt;'vMessage.Subject.Paste &lt;/P&gt;&lt;P&gt;No luck&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I tried linking directly:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;vMessage.Subject = ActiveDocument.GetSheetObject("TX01")&lt;/P&gt;&lt;P&gt;Again failed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I even tried creating a new variable:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;vText = ActiveDocument.GetSheetObject("TX01")&lt;/P&gt;&lt;P&gt;vMessage.Subject = vText&lt;/P&gt;&lt;P&gt;But this doesn't work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Nor does:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;vText= "yippee"&lt;/P&gt;&lt;P&gt;vMessage.Subject = vText&lt;/P&gt;&lt;P&gt;So that can't work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once I have a solution to this I would like to use the same method for the Sales Representative's email.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm running out of patience and time so any advice that you can offer would be appreciated&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Hope&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Oct 2011 12:57:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Email-a-report-through-Macro/m-p/246010#M93756</guid>
      <dc:creator>soton34</dc:creator>
      <dc:date>2011-10-13T12:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: Email a report through Macro</title>
      <link>https://community.qlik.com/t5/QlikView/Email-a-report-through-Macro/m-p/246011#M93757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sam,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can get the customer name via a variable and then assign its content to the subject&lt;/P&gt;&lt;P&gt; oMailDoc.Subject = "Sales Report for " &amp;amp; ActiveDocument.Variables("SelectedCustomer").GetContent.String&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The variable can be defined in Qlikview document properties: &lt;/P&gt;&lt;P&gt;only(CustomerName)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Masha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Mar 2012 13:24:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Email-a-report-through-Macro/m-p/246011#M93757</guid>
      <dc:creator>masha-ecraft</dc:creator>
      <dc:date>2012-03-03T13:24:20Z</dc:date>
    </item>
  </channel>
</rss>

