Python send mails azure protection

839 Views Asked by At
for i in range(3):
    outlook = win32.Dispatch('outlook.application')
    mail = outlook.CreateItem(0)
    mail.Subject = 'test ' + datetime.now().strftime('%#d %b %Y %H:%M')
    mail.To = "[email protected]"
    #attachment = mail.Attachments.Add(os.getcwd() + "\\")
    #attachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F", "currency_img")
    mail.HTMLBody = r"""
    Dear Carrie,<br><br>
    The highlighted of currencies exchange prices is as follow:<br><br>
    <img src="cid:currency_img"><br><br>
    For more details, you can check the table in the Excel file attached.<br><br>
    Best regards,<br>
    Yeung
    """
    mail.Attachments.Add(os.getcwd() + "\\example.xlsx")
    mail.Send()

Hi, I want do send a lot of mails via python in outlook (see code above). Unfortunately for every loop outlook wants me to confirm the protection lvl (see picture below). Is there a way to avoid protection lvl or set up a default one e.g. "Öffentlichkeit"?

enter image description here

1

There are 1 best solutions below

0
Eugene Astafiev On

To set a sensitivity label in Outlook (MSIP) you need to add a user property by using the UserProperties.Add method to an item in the following format:

"MSIP_Label_" & guid_internal_use_only & "_Enabled"

But I'd suggest exploring internals of Outlook mail items using MFCMAPI or OutlookSpy to find the exact solution. Try to set it manually then explore internals using these tools.