0 votes

Hello,

I am trying to automate a flow using a custom scenario script written in Python. I wish to send one of the outputs produced by the flow as an email attachment once the flow completes. I got this far:

sender = scenario.get_message_sender(channel_id="email_channel_id") 

sender.set_params(sender="[email protected]", recipient="[email protected]")

Not sure how to include attachments in the set_params() call.

Please note that:

  • The attachment is a file within a managed DataIku folder that is expected to be built at the end of the flow
  • It is a multi-worksheet Excel file

 

Thank you in advance for your help.

by

1 Answer

0 votes

Never mind. Figured out how to do this myself by examining the html fields in the in-built reporter form:

# Instantiate an email sender object
sender = scenario.get_message_sender(channel_id = "email_channel_id")

# Create an array of dicts: one for each attachment with: 
# - 'type' specifying the type of attachment 
# - 'params' specifying other details
attachments =[ {
  'type': 'FOLDER_ITEM',
  'params':
    {'folderId': 'folder_id',
      'attachedItemPath': 'name_of_file_in_folder'}
}]

# Set all params in the sender object
sender.set_params(sender="[email protected]", 
                 recipient="[email protected]", 
                 attachments = attachments,
                 subject="Hello", 
                 message="Test to test the testy test.")
# Send email
sender.send()

 

by
1,258 questions
1,292 answers
1,467 comments
11,809 users

┬ęDataiku 2012-2018 - Privacy Policy