SendEmailToCampaignRecipients

Send email to all recipients from the selected campaign incidents.

python · Phishing Campaign

Details

IDSendEmailToCampaignRecipients
Languagepython
From Version5.0.0
Docker Imagedemisto/python3:3.12.13.10116658

README

Send email to all recipients from the selected campaign incidents.

Script Data


Name Description
Script Type python3
Cortex XSOAR Version 5.0.0

Inputs


There are no inputs for this script.

Outputs


There are no outputs for this script.

import demistomock as demisto  # noqa: F401
from CommonServerPython import *  # noqa: F401

INVALID_EMAIL_TO_MSG = "The email to field should contain valid value"


def main():
    try:
        incident = demisto.incidents()[0]
        custom_fields = incident.get("CustomFields", {})
        emailto = custom_fields.get("campaignemailto")
        subject = custom_fields.get("campaignemailsubject")
        email_body = custom_fields.get("campaignemailbody")
        instance_to_use = custom_fields.get("campaignemailsenderinstance")
        if not emailto:
            return_error(INVALID_EMAIL_TO_MSG)

        res = demisto.executeCommand(
            "send-mail", {"to": emailto, "subject": subject, "body": email_body, "using": instance_to_use}
        )
        return_results(res)
    except Exception as ex:
        return_error(f"Failed to execute SendEmailToCampaignRecipients. Error: {ex!s}")


if __name__ in ("__main__", "__builtin__", "builtins"):
    main()