Пример #1
0
        /// <summary>
        /// Updates a specific instance of an event from another calendar in Outlook
        /// The other shared calendar must be opened in outlook before running.
        /// Utilizes the updateEvent function in the common library.
        /// </summary>
        /// <param name="subject">Title of the Event to update</param>
        /// <param name="eventDate">The date of the specific event M/d/yyyy hh:mm:ss tt</param>
        /// <param name="updatedTitle">Updated title. not required</param>
        /// <param name="updatedStartDate">Updated start date. not required</param>
        /// <param name="updatedDuration">updated duration. not required</param>
        /// <param name="otherCalendar">Name of the calendar the event is located in</param>
        /// <param name="recipients">Recipients to add to the updated event</param>
        public void UpdateOtherCalendarEvent(string subject, string eventDate, string updatedTitle, string updatedStartDate, string updatedDuration,
                                             string otherCalendar, string[] recipients)
        {
            string methodTag = "UpdateOtherCalendarEvent";

            LogWriter.WriteInfo(TAG, methodTag, "Starting: " + methodTag + " in " + TAG);

            Outlook.Application     app           = null;
            Outlook.AppointmentItem agendaMeeting = null;
            Outlook.NameSpace       NS            = null;
            Outlook.MAPIFolder      objFolder     = null;
            Outlook.MailItem        objTemp       = null;
            Outlook.Recipient       objRecip      = null;
            Outlook.Items           objItems      = null;

            app      = new Outlook.Application();
            NS       = app.GetNamespace("MAPI");
            objTemp  = app.CreateItem(Outlook.OlItemType.olMailItem);
            objRecip = objTemp.Recipients.Add(otherCalendar);
            objTemp  = null;

            LogWriter.WriteInfo(TAG, methodTag, "Attempting to resolve recipient object for: " + otherCalendar);
            objRecip.Resolve();

            if (objRecip.Resolved)
            {
                objFolder     = NS.GetSharedDefaultFolder(objRecip, Outlook.OlDefaultFolders.olFolderCalendar);
                objItems      = objFolder.Items;
                agendaMeeting = objItems.Find("[Subject]=" + subject);

                agendaMeeting = CommonLibrary.UpdateEvent(agendaMeeting, eventDate, updatedTitle, updatedStartDate, updatedDuration, recipients);

                LogWriter.WriteInfo(TAG, methodTag, "Sending event");
                agendaMeeting.Send();
                LogWriter.WriteInfo(TAG, methodTag, subject + " sucessfully sent");
            }
            else
            {
                LogWriter.WriteWarning(TAG, methodTag, "Recipient object was not sucessfully resolved");
                throw new NullReferenceException();
            }


            return;
        }
Пример #2
0
        /// <summary>
        /// Updates a specific event (a single event or one instance of a recurrence)
        /// that is currently in the main calendar of the open Outlook Application
        /// Utilizes the common methods found in the common library class
        /// </summary>
        /// <param name="subject">The subject of the event to edit</param>
        /// <param name="eventDate">The date of the specific event M/d/yyyy hh:mm:ss tt</param>
        /// <param name="updatedTitle">An updated title if desired</param>
        /// <param name="updatedStartDate">An updated start date if desired</param>
        /// <param name="updatedDuration">An updated duration if desired</param>
        /// <param name="recipients">New recipients to add</param>
        public void UpdateMainCalendarEvent(string subject, string eventDate, string updatedTitle, string updatedStartDate, string updatedDuration, string[] recipients)
        {
            string methodTag = "UpdateMainCalendarEvent";

            LogWriter.WriteInfo(TAG, methodTag, "Starting: " + methodTag + " in " + TAG);

            Outlook.Application     app           = null;
            Outlook.AppointmentItem agendaMeeting = null;
            Outlook.Items           objItems      = null;
            Outlook.MAPIFolder      objFolder     = null;

            app = new Outlook.Application();
            Outlook.NameSpace NS = app.GetNamespace("MAPI");
            agendaMeeting = (Outlook.AppointmentItem)app.CreateItem(Outlook.OlItemType.olAppointmentItem);

            objFolder = NS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
            objItems  = objFolder.Items;

            LogWriter.WriteInfo(TAG, methodTag, "Attempting to find event with subject: " + subject);

            agendaMeeting = objItems.Find("[Subject]=" + subject);

            if (agendaMeeting == null)
            {
                LogWriter.WriteWarning(TAG, methodTag, "Failed to find event with subject: " + subject);
                throw new NullReferenceException();
            }

            LogWriter.WriteInfo(TAG, methodTag, "Found event with subject: " + subject + " and updating details");

            agendaMeeting = CommonLibrary.UpdateEvent(agendaMeeting, eventDate, updatedTitle, updatedStartDate, updatedDuration, recipients);

            LogWriter.WriteInfo(TAG, methodTag, "Sending event");
            agendaMeeting.Send();
            LogWriter.WriteInfo(TAG, methodTag, subject + " sucessfully sent");

            return;
        }