found the bremen_calling_logo.png file within the client's resources. Mapping towards that file when creating email notifications. This alleviates an additional dependency.
This commit is contained in:
parent
2ea37bde56
commit
9efabf6367
@ -237,13 +237,20 @@ import typing
|
|||||||
from email.mime.application import MIMEApplication
|
from email.mime.application import MIMEApplication
|
||||||
import mimetypes
|
import mimetypes
|
||||||
|
|
||||||
def add_bremen_calling_logo(msg_multipart, path):
|
def add_bremen_calling_logo(msg_multipart):
|
||||||
"""
|
"""
|
||||||
The image is not attached automatically when it is embedded to the content. To circumvent this,
|
The image is not attached automatically when it is embedded to the content. To circumvent this,
|
||||||
one commonly creates attachments, which are referred to in the email content.
|
one commonly creates attachments, which are referred to in the email content.
|
||||||
|
|
||||||
The content body refers to 'LogoBremenCalling', which the 'Content-ID' of the logo is assigned as.
|
The content body refers to 'LogoBremenCalling', which the 'Content-ID' of the logo is assigned as.
|
||||||
"""
|
"""
|
||||||
|
# find the path towards the logo file (located at 'brecal\src\BreCalClient\Resources\logo_bremen_calling.png')
|
||||||
|
src_root_folder = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
||||||
|
resource_root_folder = os.path.join(src_root_folder, "BreCalClient", "Resources")
|
||||||
|
|
||||||
|
path = os.path.join(resource_root_folder, "logo_bremen_calling.png")
|
||||||
|
assert os.path.exists(path), f"cannot find logo of bremen calling at path: {os.path.abspath(path)}"
|
||||||
|
|
||||||
with open(path, 'rb') as file:
|
with open(path, 'rb') as file:
|
||||||
attachment = MIMEApplication(file.read(), _subtype=mimetypes.MimeTypes().guess_type(path), Name="bremen_calling.png")
|
attachment = MIMEApplication(file.read(), _subtype=mimetypes.MimeTypes().guess_type(path), Name="bremen_calling.png")
|
||||||
|
|
||||||
@ -283,7 +290,7 @@ def create_shipcall_evaluation_notification(email_handler, ship_name:str, evalua
|
|||||||
email_handler.attach_file(path, msg=msg_multipart)
|
email_handler.attach_file(path, msg=msg_multipart)
|
||||||
|
|
||||||
# add the bremen calling logo, which is referred to in the email body
|
# add the bremen calling logo, which is referred to in the email body
|
||||||
msg_multipart = add_bremen_calling_logo(msg_multipart, path=os.path.join("C:/Users/User/brecal/misc/logo_bremen_calling.png"))
|
msg_multipart = add_bremen_calling_logo(msg_multipart)
|
||||||
return (msg_multipart,content)
|
return (msg_multipart,content)
|
||||||
|
|
||||||
def send_notification(email_handler, email_tgts, msg, pwd, debug=False):
|
def send_notification(email_handler, email_tgts, msg, pwd, debug=False):
|
||||||
|
|||||||
Reference in New Issue
Block a user