This blog is about the dotnet.all types of codes,news about dotnet including asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.ncluding asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.asp.net programming,dot net programming,dotnet programs,dotnet source code,source code.

Free Hosting

Free Hosting

Tuesday, January 29, 2008

Creating Outlook appointments with C#

//First thing you need to do is add a reference to Microsoft Outlook 11.0 Object Library. Then, create new instance of Outlook.Application object:

CODE:
Outlook.Application outlookApp = new Outlook.Application ();
//Next, create an instance of AppointmentItem object and set the properties:
Outlook.AppointmentItem oAppointment = (Outlook.AppointmentItem) outlookApp.CreateItem (Outlook.OlItemType.olAppointmentItem);
oAppointment.Subject = "This is the subject for my appointment"; oAppointment.Body = "This is the body text for my appointment"; oAppointment.Location = "Appointment location";
// Set the start dateoAppointment.Start = Convert.ToDateTime ("10/10/2004 10:00:00 AM");// End date oAppointment.End = Convert.ToDateTime ("10/10/2004 2:00:00 PM");// Set the reminder 15 minutes before startoAppointment.ReminderSet = true; oAppointment.ReminderMinutesBeforeStart = 15;
//Setting the sound file for a reminder: set ReminderPlaySound = true //set ReminderSoundFile to a filename.
//Setting the importance: //use OlImportance enum to set the importance to low, medium or high
oAppointment.Importance = Outlook.OlImportance.olImportanceHigh;
/* OlBusyStatus is enum with following values:olBusyolFreeolOutOfOfficeolTentative*/oAppointment.BusyStatus = Outlook.OlBusyStatus.olBusy;
//Finally, save the appointment:
// Save the appointmentoAppointment.Save ();
// When you call the Save () method, the appointment is saved in Outlook. Another useful method is ForwardAsVcal () which can be used to send the Vcs file via email.
Outlook.MailItem mailItem = oAppointment.ForwardAsVcal (); mailItem.To = "recipients email address"; mailItem.Send ();

1 comments:

Anonymous said...

Thanks for sharing the valuable info. Is it possible to also read the contents of the msg file once its created?

Like if you check Aspose.Network library (a 3rd party component vendor), they support creating and parsing outlook message (.msg) files. For example http://www.aspose.com/documentation/utility-components/aspose.network-for-.net/loadingviewingparsing-outlook-message-msg-file.html and http://www.aspose.com/documentation/utility-components/aspose.network-for-.net/creatingsaving-outlook-message-msg-files.html. Do I have to purchase some library or I can do it easily via the Outlook dll?

dotnet(.Net) Project Source code Downloads and Tutorials

Email Subscrption



Enter your email address:

Delivered by FeedBurner

Feedburner Count

Unique Visitor

Design by araba-cı | MoneyGenerator Blogger Template by GosuBlogger