Its not a direct approach , but splunk map command comes very handy in these cases. For example in the below scenario i want to change the mail subject / email details by each host name. So i will write the logic on the main search and pass unique host and subject fields to map search.
This will send the mail results with pre-defined email id / subject by each host you have. You can alter the mail search logic as it suits your requirement.
index=myindex | dedup host|eval new_subject=(if(host=abc),"abc",none) .....etc logic|eval mail_id=If(host=abc,"
[email protected]",none).....etc logic | table host new_subject mail_id |map search=" search index=myindex host=$host$ | table _time user action other-fields ..... |eval email_to=$mail_id$ |sendresults showemail=f subject=$new_subject$ body="Body of the email"
... View more