How to initiate special messages such as meetings in C #

Source: Internet
Author: User
Tags add datetime end reference
Call the APIs in Outlook from C # to initiate special messages such as meetings. The method is as follows: After you create the project, add it. NET reference: "Microsoft.Office.Interop.Outlook" reference, you can call, note that, when added, notice the Office version number.

In the process of invoking its API initiation meeting, a problem has been encountered:

After creating an appointment entry, it took a long time to find out how to specify "sender" for this appointment, and later on, in the Window CF, there was a outlooksession to find the person information,

Does Outlook have the same way, after testing, to really find a way, originally, its API specifies that the sender is directly related to the account settings of the Outlook running on your computer.

You can find the collection of accounts you set up by ApplicationClass.Session.Accounts, and you need to be particularly aware that, here, when you take an individual, the index of the collection starts at 1, not

Starting from 0. After the associated account is found, you can specify the sender of the appointment by using the Appointmentitem.sendusingaccount property.

Here is the code for the test, run it under Win2003+office12, and successfully create the meeting:

The following are the referenced contents:

Using System;
Using System.Collections.Generic;
Using System.Text;
Using Microsoft.Office.Interop.Outlook;
/**/////////////////////
/**//* Call the Outlook API launch meeting
/* mcjeremy@cnblogs.com
////////////////////
Namespace Outlookapi
{
Class Program
{
static void Main (string[] args)
{
Try
{
ApplicationClass oapp = new Microsoft.Office.Interop.Outlook.ApplicationClass ();
A meeting is a kind of dating
AppointmentItem oitem = (AppointmentItem) oapp.createitem (Olitemtype.olappointmentitem);
Oitem.meetingstatus = olmeetingstatus.olmeeting;
Oitem.subject = "Subject";
Oitem.body = "Content";
Oitem.location = "place";
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 the whole day event
Oitem.alldayevent = false;
Oitem.busystatus = Olbusystatus.olbusy;
The index starts at 1 and not from 0
Sender's account information
Oitem.sendusingaccount = oapp.session.accounts[2];
Add a required person
Recipient force = OITEM.RECIPIENTS.ADD ("mailuser2@mailserver.com");
Force. Type = (int) olmeetingrecipienttype.olrequired;
Add an optional person
Recipient opt = OITEM.RECIPIENTS.ADD ("mailuser3@p.mailserver.com");
Opt. Type = (int) olmeetingrecipienttype.oloptional;
Add Meeting Initiator
Recipient sender = OItem.Recipients.Add ("mailuser1@mailserver.com");
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 RBC = MITEM.RECIPIENTS.ADD ("* * *");
Rbc.type = (int) olmailrecipienttype.olbcc;

Console.WriteLine ("OK");
}
catch (System.Exception ex)
{
Console.WriteLine (ex. message);
}

Console.ReadLine ();
}
}
}



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.