I need to use win32com.client
to make an email where I add a signature with the .htm
extension to the mail.HtmlBody
. However, each time I do this, I get UnicodeDecodeError
.
In other words, how do I correct the UnicodeDecodeError
problem and add my string & htm file to the HtmlBody
?
self.mail = win32.Dispatch('outlook.application').CreateItem(0)
self.curText = str(self.email.currentText())
self.projectNameT = ' '.join(self.curText.split(' ')[7:])
self.mail.To = 'ABC@XYZ.com'
self.mail.Subject = "Subject: " + str(self.projectNameT)
self.someStr = 'Hello '
self.html_url = open("SomePath//Signature.htm",encoding = 'utf16')
self.data = self.html_url.read()
self.mail.HtmlBody = self.someStr + ('<p>self.data</p>')