Skip to content

Add cc bcc csv comma delimited V2#21

Open
holstbone wants to merge 27 commits into
dataiku:masterfrom
holstbone:add-cc-bcc-csv-comma-delimited
Open

Add cc bcc csv comma delimited V2#21
holstbone wants to merge 27 commits into
dataiku:masterfrom
holstbone:add-cc-bcc-csv-comma-delimited

Conversation

@holstbone

@holstbone holstbone commented Nov 17, 2025

Copy link
Copy Markdown

@liamlynch-data - I created a clean, new pull request here.
(original PR here )

NOTES:

I did NOT incorporate changing to SMTP.send_message(msg), for two reasons:

  1. The sendmail method was selected by the Plugin dev team, so updates should probably best be led by them.
  2. There may be some ramifications to how attachments are managed.

Also, I did not incorporate hard coded CC or BCC fields, primarily because the UI/UX gets really messy. Since "Recipient" field is always pulled from the dataset, then the best UI/UX is to also always pull the "cc" and "bcc" from the dataset as well.

- Add comma-delimited CSV option
- Add cc and bcc fields
- Allow inline values for Recipient, cc, bcc
- Add comma-delimited CSV option
- Add cc and bcc fields
Remove note for feature that was not added.
- Add comma-delimited CSV option
- Add cc and bcc fields
- Add cc and bcc fields
- Add comma-delimited CSV option
Address comments
Address comment
Address comment
Address comments
Address Liam's comments
Updated to V1.0.4
Updated method per coordination with Liam
Fixed bug in handling empty cc and bcc
Fix list within list

@liamlynch-data liamlynch-data left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's much better - thanks for the changes!

Re:
I did NOT incorporate changing to SMTP.send_message(msg)
Ok no worries - perhaps we'll change it later, it doesn't matter too much

Also, I did not incorporate hard coded CC or BCC fields
Not really an issue either

There are a couple more things to address here - if you can make those changes then I'll do a full test on it (I gave it a quick test already, seems fine once I fixed that double line issue).

Comment thread custom-recipes/send-mails-from-contacts-dataset/recipe.py Outdated
Comment thread python-lib/dku_attachment_handling.py Outdated
Comment thread python-lib/dku_attachment_handling.py
Comment thread CHANGELOG.md Outdated
Comment thread python-lib/dku_email_client.py
@holstbone

Copy link
Copy Markdown
Author

@liamlynch-data - Just made final adjustments!

Comment thread CHANGELOG.md Outdated
sendmail_changes.patch
sendmail_changes.patch
sendmail_changes.patch
@holstbone

Copy link
Copy Markdown
Author

All changes from the sendmail_changes.patch have now been incorporated!

Comment thread custom-recipes/send-mails-from-contacts-dataset/recipe.py
Comment thread custom-recipes/send-mails-from-contacts-dataset/recipe.py
Comment thread custom-recipes/send-mails-from-contacts-dataset/recipe.py Outdated
Comment thread custom-recipes/send-mails-from-contacts-dataset/recipe.py Outdated
Comment thread custom-recipes/send-mails-from-contacts-dataset/recipe.py
Comment thread python-lib/dku_email_client.py
Comment thread python-lib/dku_email_client.py
Comment thread python-lib/dku_email_client.py
@liamlynch-data

liamlynch-data commented Dec 18, 2025

Copy link
Copy Markdown
Contributor

LGTM and tested. The following tests were run with the patch code applied:

Basic tests

Default: Normal email, no CC/BCC, Email body in table (text), no attachments ✅

Add CC/BCC fields ✅
With Email arrays ✅
Subject in column (e.g. status) ✅
Sender in column / value ✅

Error validation
Non-existent column for all the below: ✅
Recipient Email
Sender
CC
BCC
Email body
Subject

Values:
No body - ✅
No subject - ✅
No sender - ✅

Email body
(Email body in table)
Email body plain text - with a variable ✅
Email body html - with a variable ✅
Conditional formatting - SKIP - not relevant to change

Attachments
Excel attachment ✅
Tab delimited ✅
Comma delimited ✅

Email body plain text - with attach variable - not relevant, SKIP
Email body html - with attach variable - not relevant, SKIP

Regression
Recipe in project exported from an old version still works - with CSV tab delimited attachments ✅

Channels
Repeated above via direct SMTP settings and a channel

CC/BCC
Used an AWS SES mail channel and the dummy recipient address indicated in the messaging MTP AWS section as the sender to test CC and BCC emails (routed to addressed to me, an approved recipient) would get routed properly in the real world

@liamlynch-data liamlynch-data left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving - see previous comment for details

@liamlynch-data

Copy link
Copy Markdown
Contributor

@alexbourret @MayeulRousselet - as discussed it would be great if one of you could take a quick look, given the validation changes and the issues with multiple recipients we fixed

Comment thread CHANGELOG.md Outdated

@alexbourret alexbourret left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just update the plugin.json with the new tags and category, and maybe clarify the expected format in the cc and bcc columns

Comment thread plugin.json
Comment thread custom-recipes/send-mails-from-contacts-dataset/recipe.json Outdated
Comment thread custom-recipes/send-mails-from-contacts-dataset/recipe.json Outdated
Revise to minor update.
Adjusted language for expected data format (recipients, cc, bcc)

@RoyTeddy RoyTeddy left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regression found:
if Subject (column) or Body (column) is a datetime column we have this error:
[18:05:25] [INFO] [dku.utils] - TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'str'
Works with previous version 1.0.3 in release Version: 14.3.2 here https://released-design.qa.managedinstances.dkucloud-dev.com/projects/TEDDY_COPY/flow/

error caused by the input dataset which contains an empty row so no bug here 😅

@RoyTeddy

RoyTeddy commented Jan 20, 2026

Copy link
Copy Markdown

Found an issue but already there before:
in the Body with custom value, if we specify a dataset name with numbers like {{ attachments.16rows.html_table }}
-> beautiful error

[2026/01/20-18:25:13.499] [null-err-72] [INFO] [dku.utils]  - *************** Recipe code failed **************
[2026/01/20-18:25:13.500] [null-err-72] [INFO] [dku.utils]  - Begin Python stack
[2026/01/20-18:25:13.500] [null-err-72] [INFO] [dku.utils]  - Traceback (most recent call last):
[2026/01/20-18:25:13.501] [null-err-72] [INFO] [dku.utils]  -   File "/Users/teddy.roy@dataiku.com/devenv/DSS14/dss-home/jobs/LEGACYCFFOREXPORT/Build_send_review__NP__2026-01-20T17-25-12.075/compute_send_review_NP/custom-python-recipe/pyout4nbErQ4gweO6/python-exec-wrapper.py", line 204, in <module>
[2026/01/20-18:25:13.501] [null-err-72] [INFO] [dku.utils]  -     exec(f.read())
[2026/01/20-18:25:13.501] [null-err-72] [INFO] [dku.utils]  -   File "<string>", line 166, in <module>
[2026/01/20-18:25:13.502] [null-err-72] [INFO] [dku.utils]  -   File "/Users/teddy.roy@dataiku.com/devenv/DSS14/dss-home/code-envs/python/plugin_sendmail_managed/lib/python3.9/site-packages/jinja2/environment.py", line 1092, in from_string
[2026/01/20-18:25:13.502] [null-err-72] [INFO] [dku.utils]  -     return cls.from_code(self, self.compile(source), gs, None)
[2026/01/20-18:25:13.503] [null-err-72] [INFO] [dku.utils]  -   File "/Users/teddy.roy@dataiku.com/devenv/DSS14/dss-home/code-envs/python/plugin_sendmail_managed/lib/python3.9/site-packages/jinja2/environment.py", line 757, in compile
[2026/01/20-18:25:13.503] [null-err-72] [INFO] [dku.utils]  -     self.handle_exception(source=source_hint)
[2026/01/20-18:25:13.503] [null-err-72] [INFO] [dku.utils]  -   File "/Users/teddy.roy@dataiku.com/devenv/DSS14/dss-home/code-envs/python/plugin_sendmail_managed/lib/python3.9/site-packages/jinja2/environment.py", line 925, in handle_exception
[2026/01/20-18:25:13.504] [null-err-72] [INFO] [dku.utils]  -     raise rewrite_traceback_stack(source=source)
[2026/01/20-18:25:13.504] [null-err-72] [INFO] [dku.utils]  -   File "<unknown>", line 4, in template
[2026/01/20-18:25:13.504] [null-err-72] [INFO] [dku.utils]  - jinja2.exceptions.TemplateSyntaxError: expected token 'end of print statement', got 'rows'

it is a Python limitation.
Attributes that start with a number, such as "123property" have to be expressed as {{customer['123property']}}

so works with {{ attachments['16rows'].html_table }}
not a bug 😅

@RoyTeddy RoyTeddy left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and tested 👍
Conditional formatting works:

  • in attachements ✅
  • in body ✅

@liamlynch-data

Copy link
Copy Markdown
Contributor

Found an issue but already there before: in the Body with custom value, if we specify a dataset name with numbers like {{ attachments.16rows.html_table }} -> beautiful error

...


it is a Python limitation. Attributes that start with a number, such as "123property" have to be expressed as {{customer['123property']}}

so works with {{ attachments['16rows'].html_table }} not a bug 😅

This one seems pre-existing, nothing to do with the change, and kind of as designed (or a limitation we can't do much about) - so we can totally ignore this can't we @RoyTeddy ?
(Thanks for the thorough testing though!)

@RoyTeddy

RoyTeddy commented Feb 6, 2026

Copy link
Copy Markdown

Found an issue but already there before: in the Body with custom value, if we specify a dataset name with numbers like {{ attachments.16rows.html_table }} -> beautiful error

...


it is a Python limitation. Attributes that start with a number, such as "123property" have to be expressed as {{customer['123property']}}

so works with {{ attachments['16rows'].html_table }} not a bug 😅

This one seems pre-existing, nothing to do with the change, and kind of as designed (or a limitation we can't do much about) - so we can totally ignore this can't we @RoyTeddy ? (Thanks for the thorough testing though!)

@liamlynch-data yes we can ignore it 😉

@liamlynch-data

Copy link
Copy Markdown
Contributor

Regression found: if Subject (column) or Body (column) is a datetime column we have this error: [18:05:25] [INFO] [dku.utils] - TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'str' Works with previous version 1.0.3 in release Version: 14.3.2 here https://released-design.qa.managedinstances.dkucloud-dev.com/projects/TEDDY_COPY/flow/

error caused by the input dataset which contains an empty row so no bug here 😅

Yes this is not a regression, v 1.0.3 of the plugin does this, e.g.:
https://staging-design.qa.managedinstances.dkucloud-dev.com/projects/SENDMAIL1/datasets/ergergerg/explore/

image

@MayeulRousselet MayeulRousselet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arriving late to the party, but I have a fundamental issue: If there are multiple recipient in the same row, and 1 CC/BCC, the CC/BCC will get spammed as he receive one email per recipient.

2 solutions:

  • Cheapest: having a warning next to Recipient and CC/BCC
  • Hardest, but better: havnig the possibility to send the same email to multiple recipient (need a DSS change)

@liamlynch-data

Copy link
Copy Markdown
Contributor

Arriving late to the party, but I have a fundamental issue: If there are multiple recipient in the same row, and 1 CC/BCC, the CC/BCC will get spammed as he receive one email per recipient.

2 solutions:

  • Cheapest: having a warning next to Recipient and CC/BCC
  • Hardest, but better: havnig the possibility to send the same email to multiple recipient (need a DSS change)

I think we need to do the cheap option for now - @holstbone would you be able to add the warning? If you're not sure what needs doing I could send you a patch, but it should be simple

Re " the possibility to send the same email to multiple recipient" - we have a card already for this, but it's not scheduled:
https://app.shortcut.com/dataiku/story/233246/sendmail-add-an-option-so-if-multiple-senders-they-all-get-the-same-email

I'd also like to reiterate that we should really fix the following issue before we release with this (not necessarily in the same PR but before we release a version of the plugin):
https://app.shortcut.com/dataiku/story/298155/sendmail-plugin-wrong-column-type-for-email-fields-could-be-handled-better

@MayeulRousselet

Copy link
Copy Markdown
Contributor

Arriving late to the party, but I have a fundamental issue: If there are multiple recipient in the same row, and 1 CC/BCC, the CC/BCC will get spammed as he receive one email per recipient.
2 solutions:

  • Cheapest: having a warning next to Recipient and CC/BCC
  • Hardest, but better: havnig the possibility to send the same email to multiple recipient (need a DSS change)

I think we need to do the cheap option for now - @holstbone would you be able to add the warning? If you're not sure what needs doing I could send you a patch, but it should be simple

Re " the possibility to send the same email to multiple recipient" - we have a card already for this, but it's not scheduled: https://app.shortcut.com/dataiku/story/233246/sendmail-add-an-option-so-if-multiple-senders-they-all-get-the-same-email

I'd also like to reiterate that we should really fix the following issue before we release with this (not necessarily in the same PR but before we release a version of the plugin): https://app.shortcut.com/dataiku/story/298155/sendmail-plugin-wrong-column-type-for-email-fields-could-be-handled-better

Logged as a blocker in SH @liamlynch-data

Updated descriptions for cc_column and bcc_column to include a note about duplicate data causing multiple emails.
@holstbone

Copy link
Copy Markdown
Author

Hi @MayeulRousselet and @liamlynch-data I have updated the descriptions for cc_column and bcc_column to include a note about duplicate data causing multiple emails.

Added text: "Note: Duplicate data will cause multiple emails."

Hopefully this addresses your concern!

It looks like this now:
Screenshot 2026-04-15 at 7 21 47 PM

@holstbone

Copy link
Copy Markdown
Author

Hi @MayeulRousselet - I wanted to follow up on two items:

1.) Does my adjustment made on April 15th address your concern? See: #21 (comment)

2.) Regarding Shortcut #298155, did you actually test on this Pull Request (with the new code)? We did some better handling of types, but not certain if it specifically addresses the issue in the Shortcut. See: https://app.shortcut.com/dataiku/story/298155/sendmail-plugin-wrong-column-type-for-email-fields-could-be-handled-better

@liamlynch-data

Copy link
Copy Markdown
Contributor

Hi @MayeulRousselet - I wanted to follow up on two items:

1.) Does my adjustment made on April 15th address your concern? See: #21 (comment)

2.) Regarding Shortcut #298155, did you actually test on this Pull Request (with the new code)? We did some better handling of types, but not certain if it specifically addresses the issue in the Shortcut. See: https://app.shortcut.com/dataiku/story/298155/sendmail-plugin-wrong-column-type-for-email-fields-could-be-handled-better

Re 2) - I raised this after testing this PR, so this is something we still need to fix. But I can do it after this one is merged, no worries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants