Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Popup Outlook contact makes the WinForm stuck and hold

Popup Outlook contact makes the WinForm stuck and hold

Scheduled Pinned Locked Moved C#
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    manfree
    wrote on last edited by
    #1

    Hi all I would like to popup an Outlook contact via a Click button. The "Popup action" works fine~ However, after the outlook contact comes up, the WinForm(Form1) seem stuck and hold .... I can't move, minimize and maximize the WinForm ????? Any body know what is the problem in here ?? Thanks

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Outlook = Microsoft.Office.Interop.Outlook;

    namespace testing1
    {
    public partial class Form1 : Form
    {
    Outlook.Application oApp = new Outlook.Application();
    public Form1()
    {
    InitializeComponent();
    }

        private void Form1\_Load(object sender, EventArgs e)
        {
    
        }
        private void FindContactEmailByName(string firstName, string lastName)
        {
            Outlook.NameSpace outlookNameSpace = oApp.GetNamespace("MAPI");
            Outlook.MAPIFolder contactsFolder = outlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderContacts);
    
            Outlook.Items contactItems = contactsFolder.Items;
    
            try
            {
                Outlook.ContactItem contact = (Outlook.ContactItem)contactItems.Find(String.Format("\[FirstName\]='{0}' and " + "\[LastName\]='{1}'", firstName, lastName));
                if (contact != null)
                {
                    contact.Display(true);
                }
                else
                {
                    MessageBox.Show("The contact information was not found.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    
        private void button1\_Click(object sender, EventArgs e)
        {
            FindContactEmailByName("Tom", "Lee");
        }
    
    }
    

    }

    S 1 Reply Last reply
    0
    • M manfree

      Hi all I would like to popup an Outlook contact via a Click button. The "Popup action" works fine~ However, after the outlook contact comes up, the WinForm(Form1) seem stuck and hold .... I can't move, minimize and maximize the WinForm ????? Any body know what is the problem in here ?? Thanks

      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Data;
      using System.Drawing;
      using System.Linq;
      using System.Text;
      using System.Windows.Forms;
      using Outlook = Microsoft.Office.Interop.Outlook;

      namespace testing1
      {
      public partial class Form1 : Form
      {
      Outlook.Application oApp = new Outlook.Application();
      public Form1()
      {
      InitializeComponent();
      }

          private void Form1\_Load(object sender, EventArgs e)
          {
      
          }
          private void FindContactEmailByName(string firstName, string lastName)
          {
              Outlook.NameSpace outlookNameSpace = oApp.GetNamespace("MAPI");
              Outlook.MAPIFolder contactsFolder = outlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderContacts);
      
              Outlook.Items contactItems = contactsFolder.Items;
      
              try
              {
                  Outlook.ContactItem contact = (Outlook.ContactItem)contactItems.Find(String.Format("\[FirstName\]='{0}' and " + "\[LastName\]='{1}'", firstName, lastName));
                  if (contact != null)
                  {
                      contact.Display(true);
                  }
                  else
                  {
                      MessageBox.Show("The contact information was not found.");
                  }
              }
              catch (Exception ex)
              {
                  throw ex;
              }
          }
      
          private void button1\_Click(object sender, EventArgs e)
          {
              FindContactEmailByName("Tom", "Lee");
          }
      
      }
      

      }

      S Offline
      S Offline
      Shajeel
      wrote on last edited by
      #2

      contact.Display opens the contact window as a dialog window due to which parent window is stuck. You can call the this function in another thread if you want your parent window to work normally.

      Regards Shajeel

      M 1 Reply Last reply
      0
      • S Shajeel

        contact.Display opens the contact window as a dialog window due to which parent window is stuck. You can call the this function in another thread if you want your parent window to work normally.

        Regards Shajeel

        M Offline
        M Offline
        manfree
        wrote on last edited by
        #3

        WOW!! Thanks for your answer! it works perfect with Threading !!! ~

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups