This project has moved and is read-only. For the latest updates, please go here.
/*
   using events in Outlook
   taken from Example06.cs
*/
public partial class Form1 : Form
{
   private delegate void UpdateEventTextDelegate(string Message);
   UpdateEventTextDelegate _updateDelegate;

   public Form1()
   {
      InitializeComponent();
      _updateDelegate = new UpdateEventTextDelegate(UpdateTextbox);
   }

   private void button1_Click(object sender, EventArgs e)
   {
      // start outlook
      Outlook.Application outlookApplication = new Outlook.Application();

      Outlook.MailItem mailItem = 
outlookApplication.CreateItem(OlItemType.olMailItem) as Outlook.MailItem;
mailItem.CloseEvent +=
new NetOffice.OutlookApi.MailItem_CloseEventHandler(mailItem_CloseEvent); // BodyFormat is not available in Outlook 2000 // we check at runtime is property is available if(mailItem.EntityIsAvailable("BodyFormat")) mailItem.BodyFormat = OlBodyFormat.olFormatPlain; mailItem.Body = "dont type google into google."; mailItem.Subject = "Hello there"; mailItem.Display(); mailItem.Close(OlInspectorClose.olDiscard); // close outlook and dispose outlookApplication.Quit(); outlookApplication.Dispose(); } void mailItem_CloseEvent(ref bool Cancel) { textBoxEvents.BeginInvoke(_updateDelegate, new object[] { "Event Close called." }); } private void UpdateTextbox(string message) { textBoxEvents.AppendText(message + "\r\n"); } }

Last edited Jun 13, 2012 at 10:45 AM by SebastianDotNet, version 9

Comments

No comments yet.