<?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 How to use the sendemail command to send an email to different recipients from a lookup per event? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-sendemail-command-to-send-an-email-to-different/m-p/246094#M73378</link>
    <description>&lt;P&gt;Hi.&lt;/P&gt;

&lt;P&gt;I have a lookup object named user_email which contains a notified email list. If there is at least an event found from email_logs, based on the username within certain time range, we only need to send an email to the associated recipients with simple text such as "xyz found"  from the lookup.  For instance, this is my format of the lookup:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;username          emails
------------      ---------------------------------------------------
xyz               team1@mail.com, team2@mail.com, team3@mail.com
abc               team3@mail.com
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I use sendemail command in Splunk? &lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 09:41:08 GMT</pubDate>
    <dc:creator>splunkrocks2014</dc:creator>
    <dc:date>2020-09-29T09:41:08Z</dc:date>
    <item>
      <title>How to use the sendemail command to send an email to different recipients from a lookup per event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-sendemail-command-to-send-an-email-to-different/m-p/246094#M73378</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;

&lt;P&gt;I have a lookup object named user_email which contains a notified email list. If there is at least an event found from email_logs, based on the username within certain time range, we only need to send an email to the associated recipients with simple text such as "xyz found"  from the lookup.  For instance, this is my format of the lookup:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;username          emails
------------      ---------------------------------------------------
xyz               team1@mail.com, team2@mail.com, team3@mail.com
abc               team3@mail.com
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I use sendemail command in Splunk? &lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:41:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-sendemail-command-to-send-an-email-to-different/m-p/246094#M73378</guid>
      <dc:creator>splunkrocks2014</dc:creator>
      <dc:date>2020-09-29T09:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the sendemail command to send an email to different recipients from a lookup per event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-sendemail-command-to-send-an-email-to-different/m-p/246095#M73379</link>
      <description>&lt;P&gt;Have a look at the map command&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.0/SearchReference/Map"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.0/SearchReference/Map&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/61805/any-example-for-map-command.html"&gt;https://answers.splunk.com/answers/61805/any-example-for-map-command.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 16:29:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-sendemail-command-to-send-an-email-to-different/m-p/246095#M73379</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-05-11T16:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the sendemail command to send an email to different recipients from a lookup per event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-sendemail-command-to-send-an-email-to-different/m-p/246096#M73380</link>
      <description>&lt;P&gt;This is from another Q&amp;amp;A:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/399434/send-emailed-results-to-an-email-address-in-the-re.html#answer-399515"&gt;https://answers.splunk.com/answers/399434/send-emailed-results-to-an-email-address-in-the-re.html#answer-399515&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;If you need to send a contextually-appropriate subset of results to some people, you can skip the configuration-based email settings and do this in SPL:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | outputcsv TempFile.csv
| stats values(Email_Address) AS emailToHeader | mvexpand emailToHeader
| map search ="|inputcsv TempFile.csv | where Email_Addresss=\"$emailToHeader$\"
   | fields - Email_Address
   | sendemail
      sendresults=true inline=true
      server=\"Your.Value.Here\"
      from=\"Your.Value.Here\"
      to=\"$emailToHeader$\"
      subject=\"Your Subject here: \$name\$\"
      message=\"This report alert was generated by \$app\$ Splunk with this search string: \$search\$\""
| where comment="MakeSureNoEventsRemail"
| append [|inputcsv TempFile.csv]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 May 2016 17:15:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-sendemail-command-to-send-an-email-to-different/m-p/246096#M73380</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-05-11T17:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the sendemail command to send an email to different recipients from a lookup per event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-sendemail-command-to-send-an-email-to-different/m-p/246097#M73381</link>
      <description>&lt;P&gt;Thanks woodcock.  &lt;/P&gt;

&lt;P&gt;I got two different issues although it seems working.  Do you have any clues?&lt;BR /&gt;
1) If there aren't any findings, getting the following error: &lt;BR /&gt;
     "Error in "map": Did not find value for required attributes 'xyz'&lt;/P&gt;

&lt;P&gt;2) If there are some findings, the emails are sent out properly; however, there is an error message showed as "[subsearch]: command="sendemail", {} while sending mail to"&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2016 18:03:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-sendemail-command-to-send-an-email-to-different/m-p/246097#M73381</guid>
      <dc:creator>splunkrocks2014</dc:creator>
      <dc:date>2016-05-13T18:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the sendemail command to send an email to different recipients from a lookup per event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-sendemail-command-to-send-an-email-to-different/m-p/246098#M73382</link>
      <description>&lt;P&gt;Number 1 is "normal" and I have not found a good way to code around it.  Number 2 I have never seen before and cannot reproduce.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2016 17:39:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-sendemail-command-to-send-an-email-to-different/m-p/246098#M73382</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-06-12T17:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the sendemail command to send an email to different recipients from a lookup per event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-sendemail-command-to-send-an-email-to-different/m-p/557761#M158412</link>
      <description>&lt;P&gt;It's pretty simple, don't even need to use map command. Just enable send email alert action and in to: field set $result.email$ (email - depend upon your field name in Splunk result) and select trigger "for each result". Email will be send to the respective email address for each line of result.&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/6.3.3/Alert/Emailnotification#Send_email_to_different_recipients_based_on_search_results" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/6.3.3/Alert/Emailnotification#Send_email_to_different_recipients_based_on_search_results&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 07:43:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-sendemail-command-to-send-an-email-to-different/m-p/557761#M158412</guid>
      <dc:creator>sirajnp</dc:creator>
      <dc:date>2021-06-30T07:43:23Z</dc:date>
    </item>
  </channel>
</rss>

