[Python] Send Outlook Appointment from Different Email Address

Discussão em 'Python' iniciado por Stack, Junho 9, 2025.

  1. Stack

    Stack Membro Participativo

    Trying to automate a calendar notification by sending an outlook calendar invite via python. I would like to send the email from a separate email address. In python's email package, you can use sendmail() to specify the from_address and to_address; however, I cannot seem to figure out how to do this for an outlook invitation via win32com.client.

    I had already tried using the icalendar package to automate this process, but the ics file that is attached to the email 'is unrecognized'.

    Using win32com.client, I have been able to generate everything that I want in my invitation; however, I am still unable to figure out how to specify the sender.

    import win32com.client as win32
    from datetime import datetime
    import pytz
    tz = pytz.timezone("US/Pacific")

    start_time = tz.localize(datetime(2018, 2, 01, 16))
    subject = 'The Best Meeting Ever'
    duration = 30
    location = 'Home'

    recipient = 'recipient@example.com'
    sender = 'sender@example.com'

    outlook = win32.Dispatch('outlook.application')
    # CreateItem: 1 -- Outlook Appointment Item
    appt = outlook.CreateItem(1)

    # set the parameters of the meeting
    appt.Start = start_time
    appt.Duration = duration
    appt.Location = location
    appt.Subject = subject

    appt.MeetingStatus = 1 # this enables adding of recipients
    appt.Recipients.Add(recipient)
    appt.Organizer = sender
    appt.ReminderMinutesBeforeStart = 15
    appt.ResponseRequested = True
    appt.Save()
    appt.Send()


    when I send the email to my coworker, even though the sender is not my email address, he is receiving the invitation from my personal email and not 'sender@example.com'

    Continue reading...

Compartilhe esta Página