-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add attachment #18
Comments
I haven't implemented the ability to send attachments yet. from base64 import b64encode
with open('image.png', 'rb') as f:
img = f.read()
html = f"""
<div>
<img src="https://raw.githubusercontent.com/opulentfox-29/protonmail-api-client/master/assets/1.png" height="150" width="300" alt="image.png">
<br/>
<img src="data:image/png;base64, {b64encode(img).decode()}" height="150" width="300" alt="image.png">
</div>
"""
new_message = proton.create_message(
recipients=['to1@proton.me'],
subject='hello',
body=html,
)
message = proton.send_message(new_message, is_html=True) |
Merged
You can now send attachments and insert pictures into letter. # Create attachments
with open('image.png', 'rb') as f:
img = f.read()
with open('resume.pdf', 'rb') as f:
pdf = f.read()
img_attachment = proton.create_attachment(content=img, name='image.png')
pdf_attachment = proton.create_attachment(content=pdf, name='resume.pdf')
html = f"""
<html>
<body>
<h2>Hi, I'm a python developer, here's my photo:</h2>
<img {img_attachment.get_embedded_attrs()} height="150" width="300">
<br/>
Look at my resume, it is attached to the letter.
</body>
</html>
"""
# Send message
new_message = proton.create_message(
recipients=["to1@proton.me", "to2@gmail.com"],
subject="My first message",
body=html, # html or just text
attachments=[img_attachment, pdf_attachment],
)
sent_message = proton.send_message(new_message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I want to add an attachment when sending a mail.... I tried the following code
The text was updated successfully, but these errors were encountered: