| | |
Popup Outlook contact makes the WinForm stuck and frozen
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
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
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
C# Syntax (Toggle Plain Text)
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"); } } }
You need to run the contact launching code in a new thread, or consider using a background worker to start your FindContactEmailByName method.
Here's a tutorial on the background worker:
http://dotnetperls.com/Content/Backg...roduction.aspx
Basically, when you show a new form like that, the "owner" form that launches the contact.Display(true) call blocks until the contact is closed, or control is returned to the calling form.
Here's a tutorial on the background worker:
http://dotnetperls.com/Content/Backg...roduction.aspx
Basically, when you show a new form like that, the "owner" form that launches the contact.Display(true) call blocks until the contact is closed, or control is returned to the calling form.
Alex Cavnar, aka alc6379
![]() |
Other Threads in the C# Forum
- Previous Thread: Given a subnet mask, how to verify if an IP falls in that subnet.
- Next Thread: WPF in Linux?
| Thread Tools | Search this Thread |
.net access algorithm array asp barchart bitmap box broadcast c# check checkbox client column combobox control conversion csharp custom database databasesearch datagrid datagridview datagridviewcheckbox dataset datetime degrees development display draganddrop drawing encryption enum equation excel file form format formatting formbox forms formupdate function gdi+ image index input install java label linux list listbox mandelbrot math mouseclick mysql namevaluepairs networking operator packaging path photoshop picturebox pixelinversion post powerpacks programming radians regex remoting reporting richtextbox robot server sleep socket sql statistics stream string table text textbox thread time timer transform treeview update usercontrol validation visualstudio wait webbrowser wfa windows winforms wpf xml






