Library for generating and scheduling Email
It allows to send emails using SendGrid or Microsoft Graph.
It also contains certain utils to generate Attachments, eg using Power BI
It does store logs about sent mails in Azure Table Storage to avoid duplicate mails.
from bmsdna.mailing.attachments.static_attachment import StaticAttachment
from bmsdna.mailing.registry import GenerationInfo, daily_mail, TZONE
from datetime import datetime
from bmsdna.mailing import MailMessage
from typing import List
from datetime import time
import polars as pl
from mail_utils import get_unique_id_from_values
@daily_mail(
"tester",
"test_mail",
day_time=time(6, 0, tzinfo=TZONE),
start_date=datetime(2025, 3, 16, 6, 0, tzinfo=TZONE),
retry_on_empty_send=False,
)
async def generate_mail(info: GenerationInfo) -> List[MailMessage]:
return [
MailMessage(
entity=info.mail_name,
subject="Test Mail",
body="Test Mail",
to="some_email@other.ch",
sender="thisisasender@thing.ch",
attachments=[StaticAttachment(b"Hello World", "test.txt")],
system=info.system,
entity_id=get_unique_id_from_values( # if this one is already sent in sendgrid, won't be sent again
{
"mail_name": info.mail_name,
"system": info.system,
"date": datetime.now().strftime("%Y-%m-%d"),
}
),
body_is_html=False,
)
]
Using your own identity
By default, Azure Storage and Graph / Power BI are accessed using DefaultAzureCredential (or the Databricks service credential if USE_DR_SERVICE_CREDENTIAL is set). To use a different identity, e.g. one of your own caller, override it:
from azure.identity import ClientSecretCredential
from bmsdna.mailing.config import set_default_credential, use_credential
# process-wide
set_default_credential(ClientSecretCredential(tenant_id, client_id, client_secret))
# or only inside a block (per thread / asyncio task), takes precedence over the process-wide one
with use_credential(my_credential):
await run_jobs()
A sync TokenCredential is used for sync and (wrapped) async clients. You may additionally pass async_credential= for a native async one. You own the credential's lifecycle. Call set_default_credential() without arguments to reset.
Metadata
Release files for bmsdna-mailing 0.10.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bmsdna_mailing-0.10.0.tar.gz | 109.8 kB | With provenance | Details for bmsdna_mailing-0.10.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bmsdna_mailing-0.10.0-py3-none-any.whl | Python 3 | none | any | Details for bmsdna_mailing-0.10.0-py3-none-any.whl |
Total release size: 138.6 kB
Release files / bmsdna_mailing-0.10.0.tar.gz
| Download URL | bmsdna_mailing-0.10.0.tar.gz |
|---|---|
| Size | 109.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a745df32f75afe60a18d6541e109118659042382f96471a36a174f247379c332
|
|
BLAKE2b-256 checksum How to use checksums |
9caee5621cd9e41a1e9c1aa6efa1e8fde4814540f8b5f9b0e388caec2cf9d399
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logRelease files / bmsdna_mailing-0.10.0-py3-none-any.whl
| Download URL | bmsdna_mailing-0.10.0-py3-none-any.whl |
|---|---|
| Size | 28.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4af2d06211f51fd011963b51af67d192242d8b384eeff7636834ea8fef3637bf
|
|
BLAKE2b-256 checksum How to use checksums |
fc0a373a64d837b6cd13dc5d039a5d1b818c4571c21f6d8b94e417b87ff21261
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logSecurity for bmsdna-mailing 0.10.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for bmsdna_mailing-0.10.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.