Call the Outlook API in C # to initiate a meeting

Source: Internet
Author: User
Tags mail account

Original: Call the Outlook API in C # to initiate a meeting

In my previous article, blog post mentioned the mail server and address sent in the call outgoing e-mail in SharePoint

However, the inside method can only be used to send regular e-mails. If you want to start a special message such as a meeting, you can use Outlook's own API.

After you create the project, add it to it. NET reference: "Microsoft.Office.Interop.Outlook" reference, you can call, it should be noted that when added, pay attention to the Office version number.

A problem was encountered during the call to its API to initiate a meeting:

After creating an appointment entry, it took a long time to find out how to specify the "sender" for this appointment, and then, in a thought, window CF, find the person information there is a outlooksession of things,

So this outlook will not have the same way, after testing, and really find the method, originally, its API specifies that the sender is directly related to the account settings of Outlook running on your computer.
With ApplicationClass.Session.Accounts you can find the collection of accounts you set up, and it is particularly important to note that, here, when you fetch a person, the index of the collection starts at 1, not
Starting from 0. After you find the relevant account, you can specify the sender of the appointment by using the Appointmentitem.sendusingaccount property.
---But what if I don't use an account collection set up in Outlook and I want to specify a different mail account to send mail to? Until now there is no way to find or find ways to know that the Da people can
Point the way, bye Mr. Chia ~ ~ ~ ~

Here is the code for the test, which runs through Win2003+office12 and successfully creates the meeting:

1usingSystem;
2usingSystem.Collections.Generic;
3usingSystem.Text;
4usingMicrosoft.Office.Interop.Outlook;
5/**/////////////////////
6/**//*invoking the Outlook API to initiate a meeting
7/ * [email protected]
8////////////////////
9Namespace Outlookapi
Ten{
Oneclass Program
A    {
-static void Main (string[] args)
-        {
thetry
-            {
-ApplicationClass oapp = new Microsoft.Office.Interop.Outlook.ApplicationClass ();
-
+//Meetings are a kind of dating
-AppointmentItem oitem = (AppointmentItem) oapp.createitem (Olitemtype.olappointmentitem);
+oitem.meetingstatus = olmeetingstatus.olmeeting;
A
atoitem.subject = "Subject";
-
-Oitem.body = "Content";
-
-oitem.location = "place";
-
in//Start time
-Oitem.start = DateTime.Now.AddDays (1);
to
+//End time
-oitem.end = DateTime.Now.AddDays (2);
the
*Reminder settings
$Oitem.reminderset = true;
Panax NotoginsengOitem.reminderminutesbeforestart = 5;
-
the//Whether all-day events
+Oitem.alldayevent = false;
A
theoitem.busystatus = olbusystatus.olbusy;
+
-//Index starting from 1, not from 0
$Sender's account information
$oitem.sendusingaccount = oapp.session.accounts[2];
-
-//Add required person
theRecipient force = OITEM.RECIPIENTS.ADD ("[email protected]");
-Force . Type = (int) olmeetingrecipienttype.olrequired;
Wuyi//Add optional person
theRecipient opt = OITEM.RECIPIENTS.ADD ("[email protected]");
-opt. Type = (int) olmeetingrecipienttype.oloptional;
Wu//Add Conference Initiator
-Recipient sender = OItem.Recipients.Add ("[email protected]");
AboutSender. Type = (int) Olmeetingrecipienttype.olorganizer;
$
-OItem.Recipients.ResolveAll ();
-
-Oitem.saveas ("D:/test. MSG ", olsaveastype.olmsg);
A
+Oitem.send ();
the
-//mailitem Mitem = (MailItem) oapp.createitem (Olitemtype.olmailitem);
$Recipient rTo = MITEM.RECIPIENTS.ADD ("* * * *");
the//rto.type = (int) Olmailrecipienttype.olto;
the//recipient Rcc=mitem.recipients.add ("* * * *");
the//rcc.type = (int) OLMAILRECIPIENTTYPE.OLCC;
the//recipient RBC = MITEM.RECIPIENTS.ADD ("* * * *");
-//rbc.type = (int) olmailrecipienttype.olbcc;
in
theConsole.WriteLine ("OK");
the}
Aboutcatch (System.Exception ex)
the            {
theConsole.WriteLine (ex. Message);
the            }
+
-Console.ReadLine ();
the        }
Bayi    }
the}
the

Call the Outlook API in C # to initiate a meeting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.