Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I send multiple images using html? #94

Open
atfot opened this issue May 6, 2024 · 1 comment
Open

How can I send multiple images using html? #94

atfot opened this issue May 6, 2024 · 1 comment

Comments

@atfot
Copy link

atfot commented May 6, 2024

I really need that function but Idk how to do it. Can you show me some examples?

@stefaan1o
Copy link

stefaan1o commented May 22, 2024

I'm using a dict for the images. This way the images also have a proper name in the text and are shown inline when sending to outlook.

body_images = {
    f'plot_{i+1}': {
        "content": fig,
        'subtype': 'png',
        'maintype': 'image',
        'filename': f'plot_{i+1}.png'
    } for i, fig in enumerate(fig_list)
}

email.send(
    subject=subject,
    sender=sender,
    receivers=receivers,
    html="""
        <p>{{ bodytext }}</p>
        {{ plot_1 }}
        {{ plot_2 }}
        {{ plot_3 }}
    """,
    body_params={
        "bodytext": bodytext,
    },
    body_images=body_images,
)

Does this help you further?

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

No branches or pull requests

2 participants