<?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: How to send mail to the user in one mail if the values are combined? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409636#M118182</link>
    <description>&lt;P&gt;You could try this instead, but I haven't tested it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats values(username) as _recipients
| eval _recipients=mvjoin(_recipients, ",") 
| sendemail to=$result._recipients$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;_&lt;/CODE&gt; in front of the field name should make it invisible,but still available... Try that &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 24 May 2018 10:04:08 GMT</pubDate>
    <dc:creator>xpac</dc:creator>
    <dc:date>2018-05-24T10:04:08Z</dc:date>
    <item>
      <title>How to send mail to the user in one mail if the values are combined?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409629#M118175</link>
      <description>&lt;P&gt;Hi There,&lt;/P&gt;

&lt;P&gt;I'd like to send mails to the people from my search table, the table looks like below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;No.  username   Site   
1      a                   A       
2      b                   B
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried to use command but it sent mail to the top user in the table instead of all them.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval recipients=mvjoin(username, ";") | nomv recipients | sendemail from=xxx to=$result.recipients$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I searched mvexpand, mvcombine, but no luck, would you share your suggestion please?&lt;BR /&gt;
Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 08:55:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409629#M118175</guid>
      <dc:creator>garujoey</dc:creator>
      <dc:date>2018-05-24T08:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to send mail to the user in one mail if the values are combined?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409630#M118176</link>
      <description>&lt;P&gt;missed some comments that if the vaules are comined, then I can send mail to them in one mail, in the to list, it is "a;b"&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 09:01:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409630#M118176</guid>
      <dc:creator>garujoey</dc:creator>
      <dc:date>2018-05-24T09:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to send mail to the user in one mail if the values are combined?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409631#M118177</link>
      <description>&lt;P&gt;Hey, &lt;/P&gt;

&lt;P&gt;You could add this to your query:&lt;BR /&gt;
&lt;CODE&gt;| stats values(username) as recipients&lt;/CODE&gt;&lt;BR /&gt;
You would then get a single multi value field called recipients, which can then be combined into a single string using mvjoin -iirc, addresses must be separated by &lt;CODE&gt;,&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Hope that helps &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 09:08:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409631#M118177</guid>
      <dc:creator>xpac</dc:creator>
      <dc:date>2018-05-24T09:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to send mail to the user in one mail if the values are combined?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409632#M118178</link>
      <description>&lt;P&gt;@garujoey you should create a query with usernames and use &lt;CODE&gt;map&lt;/CODE&gt; command iterate through users and send email to each one of them.&lt;/P&gt;

&lt;P&gt;Here is an older answer for your reference: &lt;A href="https://answers.splunk.com/answers/412019/why-are-empty-emails-being-sent-using-map-sendemai.html"&gt;https://answers.splunk.com/answers/412019/why-are-empty-emails-being-sent-using-map-sendemai.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 09:16:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409632#M118178</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-24T09:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to send mail to the user in one mail if the values are combined?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409633#M118179</link>
      <description>&lt;P&gt;How's this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   (your search)
|stats values(username) as username
|eval recipients=mvjoin(username, ";")
|sendemail from=xxx to=recipients
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 May 2018 09:17:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409633#M118179</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2018-05-24T09:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to send mail to the user in one mail if the values are combined?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409634#M118180</link>
      <description>&lt;P&gt;Be aware that this makes Splunk send one mail per user, which might cause considerable overhead. Sending a single mail with multiple recipients might be more efficient. &lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 09:40:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409634#M118180</guid>
      <dc:creator>xpac</dc:creator>
      <dc:date>2018-05-24T09:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to send mail to the user in one mail if the values are combined?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409635#M118181</link>
      <description>&lt;P&gt;Thanks xpac, it should be working, I remove the sendemail part to the test first, looks good.&lt;/P&gt;

&lt;P&gt;But by adding | stats values(username) as recipients, the table will be changed as well.&lt;BR /&gt;
Is there a way to keep below search result which I need to put it into the mail body?&lt;/P&gt;

&lt;P&gt;No. username Site&lt;BR /&gt;
1 a A&lt;BR /&gt;
2 b B&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 09:54:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409635#M118181</guid>
      <dc:creator>garujoey</dc:creator>
      <dc:date>2018-05-24T09:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to send mail to the user in one mail if the values are combined?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409636#M118182</link>
      <description>&lt;P&gt;You could try this instead, but I haven't tested it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats values(username) as _recipients
| eval _recipients=mvjoin(_recipients, ",") 
| sendemail to=$result._recipients$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;_&lt;/CODE&gt; in front of the field name should make it invisible,but still available... Try that &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 10:04:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409636#M118182</guid>
      <dc:creator>xpac</dc:creator>
      <dc:date>2018-05-24T10:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to send mail to the user in one mail if the values are combined?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409637#M118183</link>
      <description>&lt;P&gt;Thanks xpac, it works well!!!&lt;/P&gt;

&lt;P&gt;I will setup an alert or report using this search query. However it will be a little different as what I setup it in the alert trigger threshold that if the result is over 1, Splunk will send mail out.&lt;/P&gt;

&lt;P&gt;By using this way, looks like Splunk will send out even the result is 0, but I will try to figure that out.&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 10:27:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409637#M118183</guid>
      <dc:creator>garujoey</dc:creator>
      <dc:date>2018-05-24T10:27:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to send mail to the user in one mail if the values are combined?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409638#M118184</link>
      <description>&lt;P&gt;True... username can be a &lt;CODE&gt;email Distribution Group&lt;/CODE&gt; then.&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 10:40:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409638#M118184</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-24T10:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to send mail to the user in one mail if the values are combined?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409639#M118185</link>
      <description>&lt;P&gt;Yes, I am going to only send one mail with multiple recipients to avoid too much duplicated mails. &lt;BR /&gt;
:)&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 10:51:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-send-mail-to-the-user-in-one-mail-if-the-values-are/m-p/409639#M118185</guid>
      <dc:creator>garujoey</dc:creator>
      <dc:date>2018-05-24T10:51:50Z</dc:date>
    </item>
  </channel>
</rss>

