I'd like to change the address while saving the email template formatting.

Asked 3 months ago, Updated 3 months ago, 5 views

I am creating an automatic mail sending program with win32com, but I used the format method to change the address to be written at the beginning of the email.


 outlook = win32 com.client.Dispatches ("Outlook.Application")

# mail.HTMLbody=mail.HTMLbody.format(name)


Dear {}, The deadline is xxx days.
Thank you for your cooperation.

Failure Example 1

Dear 〇 様, The deadline is xx days.
Thank you for your cooperation.

Failure Example 2

Dear 〇 様,

The deadline is xxx days.

Thank you for your cooperation.

However, immediately after the format method, the format (character color, font, thickness, etc.) and tabs that were set in the template were initialized.In the case of HTMLBody, all but the formatting was initialized and unnecessary line breaks were left blank for each sentence.

Is there any other way to change a specific string such as the address other than the format?
I would appreciate it if you could let me know.


2022-09-30 11:46

1 Answers

The template file (msg format) was loaded with createItemFromTemplate, but it was canceled and resolved by writing the HTML code for the template on the source code.

Editing emails in HTML format was more convenient because you can also set fonts and other settings.


outlook = win32 com.client.Dispatch("Outlook.Application")

{} Dear <br>
The deadline is <b>xxx day</b>.<br>
Thank you.



2022-09-30 11:46

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.