我需要使用win32com.client
制作电子邮件,在.htm
上添加带有mail.HtmlBody
扩展名的签名。但是,每次执行此操作时,都会得到UnicodeDecodeError
。
换句话说,如何纠正UnicodeDecodeError
问题并将我的字符串和htm文件添加到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 = '[email protected]'
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>')
[如果要使用python并完全以编程方式插入签名,则Redemption会公开实现ApplyTo方法的RDOSignature对象(它处理签名图像文件并合并HTML样式)。因为使用Outlook安全修补程序无法完成很多任务,所以您必须先解决此问题,然后才能正常进行