<?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 Sending emails using sendemail and map command not sending empty emails in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Sending-emails-using-sendemail-and-map-command-not-sending-empty/m-p/541133#M153184</link>
    <description>&lt;P&gt;I have the following question regarding using the sendemail command together with the 'map' one.&lt;/P&gt;&lt;P&gt;Using the below search I managed to send the data to respective recipients based on the results, however, when there are no results no email is being sent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup 'email_addresses + name.csv'
|  map 
    [search index=test_index
    | search name="$name$" 
    | fields name title attributes
    | stats count(eval(case(attribute="A", 1))) as "Attribute A" count(eval(case(attribute="B", 1))) as "Attribure B" count by name title _time 
    | eval _time=strftime(_time, "%+")
    | appendpipe [stats count | where count=0 ]
    | sendemail bcc="$email_address$" subject="Table $name$ | _time" sendresults=true inline=true format=table &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;lookup contains two columns: email_address and name&lt;BR /&gt;I tried different scenarios but using for example makeresults, appendpipe to insert dummy data in case no results are returned, but all caused a duplication of the email being sent, where the second email is missing the tokenization specified in the sendemail command.&lt;/P&gt;</description>
    <pubDate>Wed, 24 Feb 2021 08:01:12 GMT</pubDate>
    <dc:creator>assennikolov</dc:creator>
    <dc:date>2021-02-24T08:01:12Z</dc:date>
    <item>
      <title>Sending emails using sendemail and map command not sending empty emails</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sending-emails-using-sendemail-and-map-command-not-sending-empty/m-p/541133#M153184</link>
      <description>&lt;P&gt;I have the following question regarding using the sendemail command together with the 'map' one.&lt;/P&gt;&lt;P&gt;Using the below search I managed to send the data to respective recipients based on the results, however, when there are no results no email is being sent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup 'email_addresses + name.csv'
|  map 
    [search index=test_index
    | search name="$name$" 
    | fields name title attributes
    | stats count(eval(case(attribute="A", 1))) as "Attribute A" count(eval(case(attribute="B", 1))) as "Attribure B" count by name title _time 
    | eval _time=strftime(_time, "%+")
    | appendpipe [stats count | where count=0 ]
    | sendemail bcc="$email_address$" subject="Table $name$ | _time" sendresults=true inline=true format=table &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;lookup contains two columns: email_address and name&lt;BR /&gt;I tried different scenarios but using for example makeresults, appendpipe to insert dummy data in case no results are returned, but all caused a duplication of the email being sent, where the second email is missing the tokenization specified in the sendemail command.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 08:01:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sending-emails-using-sendemail-and-map-command-not-sending-empty/m-p/541133#M153184</guid>
      <dc:creator>assennikolov</dc:creator>
      <dc:date>2021-02-24T08:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: Sending emails using sendemail and map command not sending empty emails</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sending-emails-using-sendemail-and-map-command-not-sending-empty/m-p/541135#M153185</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/64687"&gt;@assennikolov&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I couldn't test it but please try below;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup 'email_addresses + name.csv'
|  map 
    [search index=test_index
    | search name="$name$" 
    | fields name title attributes
    | stats count(eval(case(attribute="A", 1))) as "AttributeA" count(eval(case(attribute="B", 1))) as "AttribureB" count by name title _time 
    | inputlookup append=t 'email_addresses + name.csv'
    | fillnull value="" _time, title
    | stats max(AttributeA) as "Attribute A" max(AttribureB) as "Attribure B" max(count) as count by name title _time
    | eval _time=strftime(_time, "%+")
    | sendemail bcc="$email_address$" subject="Table $name$ | _time" sendresults=true inline=true format=table &lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 24 Feb 2021 08:25:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sending-emails-using-sendemail-and-map-command-not-sending-empty/m-p/541135#M153185</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2021-02-24T08:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: Sending emails using sendemail and map command not sending empty emails</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sending-emails-using-sendemail-and-map-command-not-sending-empty/m-p/541147#M153192</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/206061"&gt;@scelikok&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your swift reply.&lt;BR /&gt;&lt;BR /&gt;The way the search is constructed always returns an additional line, which helps a lot in sending emails when there is no data. However, if I got one or more results this 'additional' line is still present. I tried to prettify it by replacing every value with "-" (fillnull). However, it looks something similar to the below table:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;Name&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;Title&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;Time&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;Attribute A&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;Attribute B&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;Total Count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;John&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;Vice President&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;&lt;SPAN&gt;Wed Feb 24&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;1&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;23&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;24&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;Bob&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;-&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;-&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;-&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;-&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you think there is a way I can get rid of the data containing dashes when there are actual results and sending only them to the respective users?&lt;BR /&gt;&lt;BR /&gt;Thank you very much for your assistance.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 10:17:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sending-emails-using-sendemail-and-map-command-not-sending-empty/m-p/541147#M153192</guid>
      <dc:creator>assennikolov</dc:creator>
      <dc:date>2021-02-24T10:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: Sending emails using sendemail and map command not sending empty emails</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sending-emails-using-sendemail-and-map-command-not-sending-empty/m-p/541217#M153224</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/64687"&gt;@assennikolov&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Please try below;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup 'email_addresses + name.csv' 
| map 
    [ search index=test_index 
    | search name="$name$" 
    | fields name title attributes 
    | stats count(eval(case(attribute="A", 1))) as "AttributeA" count(eval(case(attribute="B", 1))) as "AttribureB" count by name title _time 
    | inputlookup append=t 'email_addresses + name.csv' 
    | fillnull value="" _time, title 
    | stats max(AttributeA) as "Attribute A" max(AttribureB) as "Attribure B" max(count) as count by name title _time 
    | eventstats sum(count) as totalCount
    | where (totalCount&amp;gt;0 AND count&amp;gt;0) OR totalCount=0
    | fields - totalCount
    | eval _time=strftime(_time, "%+") 
    | sendemail bcc="$email_address$" subject="Table $name$ | _time" sendresults=true inline=true format=table&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 24 Feb 2021 13:43:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sending-emails-using-sendemail-and-map-command-not-sending-empty/m-p/541217#M153224</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2021-02-24T13:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: Sending emails using sendemail and map command not sending empty emails</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sending-emails-using-sendemail-and-map-command-not-sending-empty/m-p/541233#M153232</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/206061"&gt;@scelikok&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;It works like a charm.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 15:06:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sending-emails-using-sendemail-and-map-command-not-sending-empty/m-p/541233#M153232</guid>
      <dc:creator>assennikolov</dc:creator>
      <dc:date>2021-02-24T15:06:10Z</dc:date>
    </item>
  </channel>
</rss>

