I have a code that makes the newsletter. Everything worked on MS Office 2021, and now Office 365, and as a result, the picture in the signature is not displayed (just an empty spot in the letter).
import codecs
# below is the coding logic for signature
sig_files_path = 'AppData\Roaming\Microsoft\Signatures\' + 'signature (... account name)' + '_files\'
sig_html_path = 'AppData\Roaming\Microsoft\Signatures\' + 'signature (... account name)' + '.htm'
signature_path = os.path.join((os.environ['USERPROFILE']), sig_files_path)
html_doc = os.path.join((os.environ['USERPROFILE']), sig_html_path)
html_doc = html_doc.replace('\\', '\')
html_file = codecs.open(html_doc, 'r', errors='ignore')
signature_code = html_file.read()
signature_code = signature_code.replace(('signature (... account name)' + '_files/'), signature_path)
html_file.close()
new_path = main_report_new_path + "\Daily_Report_" + str(report_day) + ".xlsb"
office = win32com.client.Dispatch("Excel.Application")
office.Visible = True
office.DisplayAlerts = False
wb = office.Workbooks.Open(Final_Report_file)
wb.SaveAs(Filename=new_path)
wb.Close(True)
office.Quit()
outlook = win32.Dispatch('Outlook.Application')
mail = outlook.CreateItem(0)
# mail.To = '....'
mail.To = .... (emails of recipients)
mail.Subject = f'Daily Sales Report _ {report_day}'
message = """<html><body>
<font face= 'Segoe UI' size='2' color='#191970'>
Hi! <br>
There is updated report. <br>
<br>
<br>
</body></html> """
mail.Display()
mail.HTMLBody = message + signature_code
mail.Attachments.Add(new_path)
mail.Send()
4