Tuesday, 9 November 2021

Adding width and height to local image in new mail in outlook with win32com(Python)

Why I cant pass width and height to local images in img tag. Code below is working(image is displaying) but when I add width="100" height="200" to img tag image is not displayed. When I change src to image on the web src="https://i.stack.imgur.com/GafDJ.jpg?s=256&g=1" and add width="100" height="200" image is displayed with added dimensions.


import os
import win32com.client as client
outlook = client.Dispatch('Outlook.Application')

mail = outlook.CreateItem(0)
icon = os.getcwd() + '\\test.jpg'

html_body = f'''
<img src="{icon}">
<!-- <img src="https://i.stack.imgur.com/GafDJ.jpg?s=256&g=1" width="100" height="200"> -->

'''

mail.To = ''
mail.CC = ''
mail.Subject = ''
mail.HTMLBody = html_body
mail.Save()


from Adding width and height to local image in new mail in outlook with win32com(Python)

No comments:

Post a Comment