当前位置: 首页>>代码示例>>C#>>正文


C# Microsoft.Office.Interop.Outlook.Close方法代码示例

本文整理汇总了C#中Microsoft.Office.Interop.Outlook.Close方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Office.Interop.Outlook.Close方法的具体用法?C# Microsoft.Office.Interop.Outlook.Close怎么用?C# Microsoft.Office.Interop.Outlook.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Office.Interop.Outlook的用法示例。


在下文中一共展示了Microsoft.Office.Interop.Outlook.Close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: mailItem_Close

        /// <summary>
        /// WrapperEvent fired when a mailItem is closed.
        /// </summary>
        /// <param name="mailItem">the mailItem to close</param>
        /// <param name="Cancel">False when the event occurs. If the event procedure sets this argument to True,
        /// the open operation is not completed and the inspector is not displayed.</param>
        void mailItem_Close(Outlook.MailItem mailItem, ref bool Cancel)
        {
            try
            {
                if (mailItem == null)
                    return;

                // New mail (Compose)
                if (mailItem.Sent == false)
                {
                    bool toSave = false;
                    var SignProperpty = GetProperty(mailItem, "GnuPGSetting.Sign");
                    if (SignProperpty == null || (bool)SignProperpty != ribbon.SignButton.Checked)
                    {
                        toSave = true;
                    }

                    var EncryptProperpty = GetProperty(mailItem, "GnuPGSetting.Decrypted");
                    if (EncryptProperpty == null || (bool)EncryptProperpty != ribbon.EncryptButton.Checked)
                    {
                        toSave = true;
                    }
                    if (toSave == true)
                    {
            #if DISABLED
            BoolEventArgs ev = e as BoolEventArgs;
            DialogResult res = MessageBox.Show("Do you want to save changes?",
                                           "OutlookGnuPG",
                                           MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
            if (res == DialogResult.Yes)
            {
              // Must call mailItem.Write event handler (mailItem_Save) explicitely as it is not always called
              // from the mailItem.Save() method. Mail is effectly saved only if a property changed.
              mailItem_Save(sender, EventArgs.Empty);
              mailItem.Save();
            }
            if (res == DialogResult.Cancel)
            {
              ev.Value = true;
            }
            #else
                        // Invalidate the mailItem to force Outlook to ask to save the mailItem, hence calling
                        // the mailItem_Save() handler to record the buttons state.
                        // Note: the reason (button state property change) to save the mailItem is not necessairy obvious
                        // to the user, certainly if nothing has been updated/changed by the user. If specific notification
                        // is required see DISABLED code above. Beware, it might open 2 dialog boxes: the add-in custom and
                        // the regular Outlook save confirmation.
                        mailItem.Subject = mailItem.Subject;
                    }
            #endif
                }
                else
                {
                    var SignProperty = GetProperty(mailItem, "GnuPGSetting.Decrypted");
                    if (SignProperty != null && (bool)SignProperty)
                    {
                        mailItem.Close(Microsoft.Office.Interop.Outlook.OlInspectorClose.olDiscard);
                    }
                }
            }
            catch
            {
                // Ignore random COM errors
            }
        }
开发者ID:ktw,项目名称:OutlookPrivacyPlugin,代码行数:71,代码来源:OutlookPrivacyPlugin.cs

示例2: mailItem_Close

		/// <summary>
		/// WrapperEvent fired when a mailItem is closed.
		/// </summary>
		/// <param name="mailItem">the mailItem to close</param>
		/// <param name="Cancel">False when the event occurs. If the event procedure sets this argument to True,
		/// the open operation is not completed and the inspector is not displayed.</param>
		void mailItem_Close(Outlook.MailItem mailItem, ref bool Cancel)
		{
			try
			{
				if (mailItem == null)
					return;

				// New mail (Compose)
				if (mailItem.Sent == false)
				{
					var toSave = false;
					var signProperpty = GetProperty(mailItem, "GnuPGSetting.Sign", false);
					if (signProperpty == null || (bool)signProperpty != _ribbon.SignButton.Checked)
					{
						toSave = true;
					}

					var encryptProperpty = GetProperty(mailItem, "GnuPGSetting.Decrypted", false);
					if (encryptProperpty == null || (bool)encryptProperpty != _ribbon.EncryptButton.Checked)
					{
						toSave = true;
					}

                    SetProperty(mailItem, "GnuPGSetting.Sign", false);
                    SetProperty(mailItem, "GnuPGSetting.Encrypt", false);

					if (toSave == true)
					{
#if DISABLED
		BoolEventArgs ev = e as BoolEventArgs;
		DialogResult res = MessageBox.Show("Do you want to save changes?",
										   "OutlookGnuPG",
										   MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
		if (res == DialogResult.Yes)
		{
		  // Must call mailItem.Write event handler (mailItem_Save) explicitely as it is not always called
		  // from the mailItem.Save() method. Mail is effectly saved only if a property changed.
		  mailItem_Save(sender, EventArgs.Empty);
		  mailItem.Save();
		}
		if (res == DialogResult.Cancel)
		{
		  ev.Value = true;
		}
#else
						// Invalidate the mailItem to force Outlook to ask to save the mailItem, hence calling
						// the mailItem_Save() handler to record the buttons state.
						// Note: the reason (button state property change) to save the mailItem is not necessairy obvious
						// to the user, certainly if nothing has been updated/changed by the user. If specific notification
						// is required see DISABLED code above. Beware, it might open 2 dialog boxes: the add-in custom and
						// the regular Outlook save confirmation.
						mailItem.Subject = mailItem.Subject;
					}
#endif
				}
				else
				{
                    SetProperty(mailItem, "GnuPGSetting.Sign", false);
                    SetProperty(mailItem, "GnuPGSetting.Encrypt", false);

                    var signProperty = GetProperty(mailItem, "GnuPGSetting.Decrypted");
                    SetProperty(mailItem, "GnuPGSetting.Decrypted", false);

                    if (signProperty != null && (bool)signProperty)
					{
                        // NOTE: Cannot call mailItem.Close from Close event handler
                        //       instead we will start a timer and call it after we
                        //       return. There is a small race condition, but 250
                        //       milliseconds should be enough even on slow machines.

                        var timer = new Timer { Interval = 250 };
                        timer.Tick += new EventHandler((o, e) =>
						{
                            timer.Stop();
                            mailItem.Close(
								_settings.SaveDecrypted ? Outlook.OlInspectorClose.olSave : Outlook.OlInspectorClose.olDiscard);
                        });

					    timer.Start();

						Cancel = true;
					}
				}
			}
			catch
			{
				// Ignore random COM errors
			}
		}
开发者ID:ALange,项目名称:OutlookPrivacyPlugin,代码行数:95,代码来源:OutlookPrivacyPlugin.cs


注:本文中的Microsoft.Office.Interop.Outlook.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。