Original article: Outlook meeting room
However, the method can only be used to send normal emails. If you want to initiate special emails such as meetings, you can use C # To Call The outlook API and its own API.
After creating a project, add it. net reference: "Microsoft. office. interOP. outlook "reference, you can call it, note that when adding, pay attention to the office version number.
C # encountered a problem when calling the outlook API to initiate a meeting:
After creating an appointment, I have not found how to specify a sender for this appointment for a long time. Later I thought that in window CF, The lookup personnel information had an outlooksession,
Will outlook be in the same way? After testing, I found the method. Originally, the sender specified by its API was directly related to the account settings of outlook running on your machine.
You can use applicationclass. session. Accounts to find the set of accounts you set. Note that the index of the set starts from 1 when a person is retrieved.
Starts from 0. After finding the relevant account, you can use the appointmentitem. sendusingaccount attribute to specify the sender of the appointment. However, if I do not use the account set in outlook, but want to specify other email accounts to send emails, what should I do? No way has been found or found up till now, and people who want to know can
Give me some advice and thank you ~~~~
The test code is as follows:
- Using system;
- Using system. Collections. Generic;
- Using system. text;
- Using Microsoft. Office. InterOP. outlook;
- ////////////////////
- /* Call the outlook API to initiate a meeting
- /* [Email protected]
- ////////////////////
- Namespace outlookapi
- {
- Class Program
- {
- Static void main (string [] ARGs)
- {
- Try
- {
- Applicationclass oapp =
- New Microsoft. Office. InterOP. Outlook. applicationclass ();
-
- // Meeting is a type of appointment.
- Appointmentitem oitem = (appointmentitem) oapp. createitem (
- Olitemtype. olappointmentitem );
- Oitem. meetingstatus = olmeetingstatus. olmeeting;
-
- Oitem. Subject = "topic ";
-
- Oitem. Body = "content ";
-
- Oitem. Location = "location ";
-
- // Start time
- Oitem. Start = datetime. Now. adddays (1 );
-
- // End Time
- Oitem. End = datetime. Now. adddays (2 );
-
- // Reminder settings
- Oitem. reminderset = true;
- Oitem. reminderminutesbeforestart = 5;
-
- // Whether it is a full-day event
- Oitem. alldayevent = false;
-
- Oitem. busystatus = olbusystatus. olbusy;
-
- // Index starts from 1 instead of 0
- // Sender's account information
- Oitem. sendusingaccount = oapp. session. Accounts [2];
-
- // Add a required person
- Recipient force = oitem. Recipients. Add ("[email protected]");
- Force. type = (INT) olmeetingrecipienttype. olrequired;
- // Add optional persons
- Recipient opt = oitem. Recipients. Add ("[email protected]");
- Opt. type = (INT) olmeetingrecipienttype. oloptional;
- // Add the meeting Initiator
- Recipient sender = oitem. Recipients. Add ("[email protected]");
- Sender. type = (INT) olmeetingrecipienttype. olorganizer;
-
- Oitem. Recipients. resolveall ();
-
- // Oitem. saveas ("D:/test. MSG", olsaveastype. olmsg );
-
- Oitem. Send ();
-
- // Mailitem mitem = (mailitem) oapp. createitem (olitemtype. olmailitem );
- // Recipient RTO = mitem. Recipients. Add ("****");
- // RTO. type = (INT) olmailrecipienttype. olto;
- // Recipient RCC = mitem. Recipients. Add ("****");
- // RCC. type = (INT) olmailrecipienttype. OLCC;
- // Recipient rb= mitem. Recipients. Add ("****");
- // RBC. type = (INT) olmailrecipienttype. olbcc;
-
- Console. writeline ("OK ");
- }
- Catch (system. Exception ex)
- {
- Console. writeline (ex. Message );
- }
-
- Console. Readline ();
- }
- }
- }
The preceding section describes how to call the outlook API in C.
Outlook meeting room