Reporting

sendmail to multiple users based on table output

harryvdtol
Path Finder

Hello,


I want to send multiple mails, based on the data in the seearch results.
I have tried many posts, but i am still unable to get this working.

For each email address i want to send an email.
In my example i want to send 2 emails.

This is my query example

 

| makeresults
| eval kol1="line-1",kol2="line-1", email="j.doe@splunk.com"
| append [ | makeresults | eval kol1="line-2",kol2="line-2", email="j.doe@splunk.com" ]
| append [ | makeresults | eval kol1="line-3",kol2="line-3", email="j.doe@splunk.com" ]
| append [ | makeresults | eval kol1="line-1",kol2="line-1", email="p.doe@splunk.com" ]
| append [ | makeresults | eval kol1="line-2",kol2="line-2", email="p.doe@splunk.com" ]
| table kol1 kol2 email
| map search="|makeresults |sendemail to="$email$" from="me@sample.com" incline=true sendresults=true subject="test" message=$kol1$ $kol2$"

The result is, that i a getting 5 emails, with a content of only kol1 as message


I am thinking of alternatives, but that looks to complicated for now , like this...
https://community.splunk.com/t5/Splunk-Cloud-Platform/Send-email-to-multiple-users-with-respective-d...

Is it somehow possible to do get this working?

Regards,

Harry

Labels (2)
0 Karma
1 Solution

harryvdtol
Path Finder

I am going to do it in two steps
Make an outputlookup for the data.
And with another search inputlookup and this commanmd

| inputlookup mytempdata.csv
| stats values(email) as email
| mvexpand email
| map search="
    | inputlookup mytempdata.csv
    | where match(email, \"^$email$\")
    | sendemail
        to=\"$email$\"
        subject=\"My Subject\"
        message=\"My Message\"
        sendresults=true
        inline=true 
        format=table 
        sendpdf=false 
        sendcsv=false
    " maxsearches=100

View solution in original post

0 Karma

harryvdtol
Path Finder

And it works

0 Karma

harryvdtol
Path Finder

I am going to do it in two steps
Make an outputlookup for the data.
And with another search inputlookup and this commanmd

| inputlookup mytempdata.csv
| stats values(email) as email
| mvexpand email
| map search="
    | inputlookup mytempdata.csv
    | where match(email, \"^$email$\")
    | sendemail
        to=\"$email$\"
        subject=\"My Subject\"
        message=\"My Message\"
        sendresults=true
        inline=true 
        format=table 
        sendpdf=false 
        sendcsv=false
    " maxsearches=100
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...