0

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>')
Bilal Siddiqui
  • 349
  • 3
  • 17

1 Answers1

0

If you want to insert a signature in using python and fully programatically, Redemption exposes the RDOSignature object which implements ApplyTo method (it deals with signature image files and merges HTML styles). Because with the outlook security patch, a lot is unable to be done inherrently, so you must work around this before you can procede as normal

ItsMeNaira
  • 360
  • 1
  • 12