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:
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.