I am using python to automate some outlook email replies and I need to remove the "RE:" from the subject when using the email.ReplyAll(), I tried to do email.Subject = subject before replying but it still adds the "RE:".
FYI, I do not intend to remove the default functionality of Outlook to add "RE:" when replying to emails. I only intend to remove it when using the python script.
import win32com.client
num_emails_limit = 10 #Loops through last 10 emails in folder
folder_name = 'Sent Items' #Name of Outlook folder I want to search
#Opens Outlook application
outlook_application = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
outlook_mailbox = outlook_application.Folders.Item(1)
#Finds the correct Outlook Folder by searching for a folder that is equal to folder_name
for folder in outlook_mailbox.Folders:
if folder.Name == folder_name:
found_folder = folder
Filter = "[Subject] = 'SomeWord'"
folder_emails = found_folder.Items.Restrict(Filter)
folder_emails.Sort("[ReceivedTime]", True)
#Loops Through Outlook Emails
counter = 0
for email in folder_emails:
try:
email_subject = str(email.Subject)
print('Subject: ' + email_subject)
counter = counter +1
except:
pass
#If the email I want to reply to contains "SomeWord"
if "SomeWord" in email.Subject:
#Change the subject to "OtherWord"
subject = "OtherWord"
email.Subject = subject
email.ReplyAll().Display()
if counter == num_emails_limit:
break
So using this code the Subject of the email will be "RE: OtherWord" instead of just "OtherWord". Is there any way to fix this?