File size: 980 Bytes
c1c7334
e382003
 
 
c1c7334
 
 
 
 
 
 
 
 
 
 
c8801b5
c1c7334
 
c8801b5
 
c1c7334
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from email.message import EmailMessage
from prompts.prompts_manager import Questions
from prompts.prompts_manager import PromptsManager
from repository import Repository


class EmailManager:

    def __init__(self, pm: PromptsManager, repository:Repository):
        self.pm = pm
        self.repository = repository

    def create_email(self, answers: dict[Questions, str], pdf_form, filename) -> EmailMessage:
        msg = EmailMessage()
        msg["Subject"] = (f"Minor work permit for unit {answers[Questions.UNIT_APT_NUMBER]} in "
                          f"{answers[Questions.BUILDING]}, {answers[Questions.COMMUNITY]}")
        msg["From"] = answers[Questions.YOUR_EMAIL]
        msg["To"] = "[email protected]"
        message = self.repository.send_prompt(self.pm.compose_email(answers), True)["content"]
        msg.set_content(message, cte="8bit")
        msg.add_attachment(pdf_form, maintype="application", subtype="pdf", filename=filename)
        return msg