How to create an Outlook meeting request with an alternate sender / organizer?

I developed a Python application to automate sending email messages and meeting requests for internal office events. To separate them from regular messages, we created an alternative email address that I can use to send official announcements. I modified my application to handle this for emails using SentOnBehalfOfName for the alternate sender, however I was not able to duplicate it for meeting requests. My attempt is based on a series of search queries. However, at startup this results in an error:

 Traceback (most recent call last): File "mailer_test.py", line 49, in <module> test_sender) File "mailer_test.py", line 38, in send_meeting_request mtg.Send() File "<COMObject CreateItem>", line 2, in Send pywintypes.com_error: (-2147024809, 'The parameter is incorrect.', None, None) 

This happens when I add an option for an alternate sender - deleting this result leads to a successful message from my account. The test code that reproduces the error is below - I deleted my actual email address, but everything else is the same.

 import win32com.client OUTLOOK_APPOINTMENT_ITEM = 1 OUTLOOK_MEETING = 1 OUTLOOK_ORGANIZER = 0 OUTLOOK_OPTIONAL_ATTENDEE = 2 ONE_HOUR = 60 THIRTY_MINUTES = 30 OUTLOOK_FORMAT = '%m/%d/%Y %H:%M' outlook_date = lambda dt: dt.strftime(OUTLOOK_FORMAT) class OutlookClient(object): def __init__(self): self.outlook = win32com.client.Dispatch('Outlook.Application') def send_meeting_request(self, subject, time, location, recipients, body, sender=None): mtg = self.outlook.CreateItem(OUTLOOK_APPOINTMENT_ITEM) mtg.MeetingStatus = OUTLOOK_MEETING mtg.Location = location if sender: # Want to set the sender to an address specified in the call # This is the portion of the code that does not work organizer = mtg.Recipients.Add(sender) organizer.Type = OUTLOOK_ORGANIZER for recipient in recipients: invitee = mtg.Recipients.Add(recipient) invitee.Type = OUTLOOK_OPTIONAL_ATTENDEE mtg.Subject = subject mtg.Start = outlook_date(time) mtg.Duration = ONE_HOUR mtg.ReminderMinutesBeforeStart = THIRTY_MINUTES mtg.ResponseRequested = False mtg.Body = body mtg.Send() if __name__ == "__main__": import datetime ol = OutlookClient() meeting_time = datetime.datetime.now() + datetime.timedelta(hours=3) test_recipients = [' me@example.com '] test_sender = ' alternate@example.com ' ol.send_meeting_request('Test Meeting', meeting_time, 'Nowhere', test_recipients, 'This is a test meeting.', test_sender) 

Note. This is not a problem with this question , since I am not using C #, nor am I trying to edit the meeting request after the fact.

Update: As Marnix Klooster suggested, I was looking through the user interface to see how I can do this, and it doesn't seem easy (if possible). The only way I did this is to log in to another user’s calendar and create a new meeting there and add invitees. This mailbox is added by going to the Advanced tab using the More Settings... button in the Server More Settings... dialog box displayed when changing Account Settings . An alternative answer to this question will be how to use this mailbox as the default creator when accessing Outlook through COM.

+6
source share
1 answer

According to this page , you can send meeting requests on behalf of another person, but you need to have access to this calendar. The other person should designate you as a delegate.

-1
source

Source: https://habr.com/ru/post/909106/


All Articles