I want to attach the JSON data to the mail which is sent by ElasticSearch Watcher. I know how to do it through REST APIs but don't know how to do it through JAVA API.
Till now I have this :
EmailTemplate.Builder emailBuilder = EmailTemplate.builder();
emailBuilder.to(reqAlert.getEmail());
emailBuilder.subject(reqAlert.getSubject());
emailBuilder.textBody(reqAlert.getBody());
I am following this for reference. Please help me out.
Try this:
import org.elasticsearch.watcher.actions.email.DataAttachment;
import org.elasticsearch.watcher.actions.email.service.Attachment;
...
Map<String, Object> data = ImmutableMap.<String, Object>of("key", "value");
Attachment attachment = DataAttachment.JSON.create(data);
emailBuilder.attach(attachment);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.