none
Adding events to Outlook Calendar RRS feed

  • Question

  • Hi,

         I Have a Requirement where i need to add some events to outlook calender and i am doing it in the following way

                   Type outlookType = Type.GetTypeFromProgID("Outlook.Application", true);
                    if (outlookType != null)
                    {

    _Application olApp = (_Application)new Application();
                            NameSpace mapiNS = olApp.GetNamespace("MAPI");

                            string profile = "";
                            mapiNS.Logon(profile, null, null, null);

                            _AppointmentItem apt = (_AppointmentItem)
                                    olApp.CreateItem(OlItemType.olAppointmentItem);

                            // set some properties
                            apt.Subject = eventname;
                            apt.Body = eventname;

                            apt.Start = new DateTime(int.Parse(_Year.ToString()), int.Parse(_Month.ToString()), int.Parse(_Day.ToString()), istartHours, istartMinutes, 00);
                            apt.End = new DateTime(int.Parse(_Year.ToString()), int.Parse(_Month.ToString()), int.Parse(_Day.ToString()), iendHours, iendMinutes, 00);

                            apt.ReminderMinutesBeforeStart = 15;
                            apt.BusyStatus = OlBusyStatus.olTentative;

                            apt.AllDayEvent = false;
                            apt.Location = strloc;
                            apt.Save();

    }

    By the above code the event is getting added in my Outlook calendar from my development environment. And when i hosted the code on server its giving me NULL reference Error.

    MY Question is 

    1) Do we need Outlook or necessary DLL's to be installed on the server too?

    2) If No what needs to be changed?


    Regards, Dillu

    • Moved by JesB Friday, April 26, 2013 5:20 PM Development question
    • Moved by Quist ZhangModerator Monday, April 29, 2013 2:58 AM
    Friday, April 26, 2013 7:33 AM

All replies