예제 #1
0
 private void SetOutlookAppointmentUserId(_AppointmentItem aptItem)
 {
     OutlookInterop.AppointmentItem olApt = (OutlookInterop.AppointmentItem)aptItem;
     OutlookInterop.UserProperty    prop  = olApt.UserProperties.Add(OutlookUserPropertyName, OutlookInterop.OlUserPropertyType.olNumber, false, System.Reflection.Missing.Value);
     try {
         prop.Value = UserID;
     } finally {
         Marshal.ReleaseComObject(prop);
     }
 }
예제 #2
0
        public static string FormatOutlookAppointmentString(_AppointmentItem olApt)
        {
            if (olApt == null)
            {
                return("Null");
            }

            string isRecurring = olApt.IsRecurring ? "Recurring" : "NonRecurring";

            return(String.Format("[{0}] {1}", isRecurring, olApt.Subject));
        }
        private void SetOutlookAppointmentContactInfo(_AppointmentItem aptItem, string contactInfo)
        {
            OutlookInterop.AppointmentItem olApt = (OutlookInterop.AppointmentItem)aptItem;
            OutlookInterop.UserProperty    prop  = olApt.UserProperties.Add(OutlookUserPropertyName, OutlookInterop.OlUserPropertyType.olText, false, Missing.Value);

            try {
                prop.Value = contactInfo;
            }
            finally {
                Marshal.ReleaseComObject(prop);
            }
        }
        protected override List <_AppointmentItem> PrepareItemsForExchange(_Items items)
        {
            List <_AppointmentItem> result = new List <_AppointmentItem>();

            if (items == null)
            {
                return(result);
            }

            string           filter = FormatInterval(Interval);
            _AppointmentItem olApt  = items.Find(filter) as _AppointmentItem;

            while (olApt != null)
            {
                result.Add(olApt);
                olApt = items.FindNext() as _AppointmentItem;
            }
            return(result);
        }
예제 #5
0
        private int GetOutlookAppointmentUserId(_AppointmentItem aptItem)
        {
            OutlookInterop.AppointmentItem olApt = (OutlookInterop.AppointmentItem)aptItem;
            IEnumerator en = olApt.UserProperties.GetEnumerator();

            en.Reset();
            while (en.MoveNext())
            {
                OutlookInterop.UserProperty prop = (OutlookInterop.UserProperty)en.Current;
                try {
                    if (prop.Name == OutlookUserPropertyName)
                    {
                        return(Convert.ToInt32(prop.Value));
                    }
                } finally {
                    Marshal.ReleaseComObject(prop);
                }
            }
            return(-1);
        }
예제 #6
0
        protected void btn_create_Click(object sender, EventArgs e)
        {
            try
            {
                _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 = txt_subject.Text;
                apt.Body    = txt_content.Text;
                apt.Start   = Convert.ToDateTime(txt_start.Text);
                apt.End     = Convert.ToDateTime(txt_end.Text);
                apt.ReminderMinutesBeforeStart = 15;            // One week
                apt.BusyStatus = OlBusyStatus.olTentative;      // Makes it appear bold in the calendar - which I like!
                if (chk_eventtype.Checked == true)
                {
                    apt.AllDayEvent = true;
                }
                else
                {
                    apt.AllDayEvent = false;
                }
                apt.Location = txt_location.Text;
                //apt.Save();
                apt.Display(olApp);
                //ScriptManager.RegisterStartupScript(this, typeof(string), "close", "alert('Appointment Created');", true);
            }
            catch
            {
                throw;
            }
        }
 /// <summary>
 /// Gets the property value for a <see cref="_AppointmentItem">_AppointmentItem</see> user property.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="appointment">The contact item.</param>
 /// <param name="name">The name of the user property.</param>
 /// <param name="type">The type of the user property.</param>
 /// <param name="create">if set to <c>false</c> the property will not be created if it doesn't exist.</param>
 /// <param name="converter">The converter to use to convert the object to.</param>
 /// <param name="defaultValue">The default value to use if user property not found.</param>
 /// <returns>User property vlaue or default</returns>
 public static T GetPropertyValue <T>(this _AppointmentItem appointment, string name, OlUserPropertyType type, bool create, Func <object, T> converter, T defaultValue)
 {
     using (var userProperties = appointment.UserProperties.WithComCleanup())
         return(GetPropertyValue(userProperties.Resource, name, type, create, converter, defaultValue));
 }
 /// <summary>
 /// Sets the user property value.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="contactItem">The appointment item.</param>
 /// <param name="name">The name of the user property to set.</param>
 /// <param name="type">The type of the user property.</param>
 /// <param name="value">The value to set.</param>
 /// <param name="addToFolder">if set to <c>true</c> add to containing folder. Enables search/display column for user property.</param>
 public static void SetPropertyValue <T>(this _AppointmentItem contactItem, string name, OlUserPropertyType type, T value, bool addToFolder)
 {
     using (var userProperties = contactItem.UserProperties.WithComCleanup())
         SetPropertyValue(userProperties.Resource, name, type, value, addToFolder);
 }
예제 #9
0
        public static string FormatOutlookAppointmentString(_AppointmentItem olApt)
        {
            if (olApt == null)
                return "Null";

            string isRecurring = olApt.IsRecurring ? "Recurring" : "NonRecurring";
            return String.Format("[{0}] {1}", isRecurring, olApt.Subject);
        }