-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from SmartReports/dev
Dev
- Loading branch information
Showing
5 changed files
with
116 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
from .sync_db_kb import get_kpi_value | ||
from base64 import b64decode | ||
from django.template.loader import render_to_string | ||
from django.core.mail import send_mail | ||
|
||
def send_emails_for_unsent_reports(): | ||
# Get distinct user types from UserType enumeration | ||
|
@@ -103,3 +104,43 @@ def send_emails_for_alarms(): | |
# Send the email | ||
print(f'Success: {email.send()== 1}') | ||
|
||
|
||
def mail_final_presentation(): | ||
from email.mime.image import MIMEImage | ||
from django.core.mail import EmailMultiAlternatives | ||
|
||
|
||
subject = 'Reporting on wearable device' | ||
body_html = ''' | ||
<html> | ||
<body> | ||
<p>Dear Sandra,</p> | ||
<p>We regret to inform you that there seems to be an issue with the wearable device n°1234. </p> | ||
<p>We encourage you to contact the doctor and to check the functioning of the device through your dashboard or the virtual assistant. </p> | ||
<p>Kind regards,<br>The Smartreports team</p> | ||
<img src="cid:yellow.png" width="300" /> | ||
</body> | ||
</html> | ||
''' | ||
|
||
from_email = settings.DEFAULT_FROM_EMAIL | ||
|
||
msg = EmailMultiAlternatives( | ||
subject, | ||
body_html, | ||
from_email=from_email, | ||
to=['[email protected]', '[email protected]'], | ||
# to=['[email protected]'], | ||
# to=['[email protected]'] | ||
|
||
) | ||
|
||
msg.mixed_subtype = 'related' | ||
msg.attach_alternative(body_html, "text/html") | ||
image = 'yellow.png' | ||
with open('/home/matteo/smartreports-backend/smartreport_app/yellow.png', 'rb') as f: | ||
img = MIMEImage(f.read()) | ||
img.add_header('Content-ID', '<{name}>'.format(name=image)) | ||
img.add_header('Content-Disposition', 'inline', filename=image) | ||
msg.attach(img) | ||
print(msg.send(fail_silently=False)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.