dataiku library messagesender Email CC

NN
NN Neuron, Registered, Neuron 2022, Neuron 2023, Circle Member Posts: 150 Neuron

Hi All,
I am trying to use the MessageSender to send some emails in custom recipes.
I was hoping if there is a way to pass the CC email list in the send function
Please do let me know if there any suggestions or alternatives

from dataiku.core.message_sender import MessageSender
s = MessageSender(channel_id='SMTP', type='mail-scenario', configuration={})
s.send(message=somehtml, subject=subject, recipient=email_list, sender=from_address,
sendAsHTML=True)

Thanks

Operating system used: RHEL7

Best Answer

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,580 Neuron
    Answer ✓

    It's much better to use the new send() mail API which doesn't need a scenario and can run from anywhere. Note that to/cc/bcc expect list parameters:

    import dataiku
    client = dataiku.api_client()
    mail_channel = client.get_messaging_channel("SMTP")
    mail_channel.send(project_key=client.get_default_project().project_key, to=["joe@gmail.com"], subject="Hello there!", body="‹html><body›Some HTML body</body></html>", attachments=None, plain_text=False, sender=None, cc=None, bcc=None)
    

Answers

  • NN
    NN Neuron, Registered, Neuron 2022, Neuron 2023, Circle Member Posts: 150 Neuron
    edited July 9

    Thanks @Turribeach While this works, there is one issue with this .
    Seems i cannot send a single email to multiple recipients using this method.
    If we pass multiple emailids to the TO=List then the process sends out separate emails each to each of the recipients instead of one email marking them all.

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,580 Neuron

    Yeah we saw the same behavior. Not sure why Dataiku does this, perhaps to protect the identity of each To recipient? Not a big issue for us. But if it bothers you that much create an internal distribution list in your corporate email and use that instead. It's best practice to do that since you can have the process owner own the distribution list so that it can be updated as needed rather than having to make changes in Dataiku. I might ping Dataiku Support to ask why they do this, it's a bit puzzling…

  • NN
    NN Neuron, Registered, Neuron 2022, Neuron 2023, Circle Member Posts: 150 Neuron

    The emails which are sent from the scenario reporters can be marked to multiple users in one mail itself. So there may be some way to do this, will leave a note here if i find something else at my end as well.

    Thanks Again.

Setup Info
    Tags
      Help me…