Save and Close doesn't close

W

Will

This was originally posted to microsoft.public.outlook.interop.

Using the Office XP PIA's, I've built an Outlook add-in with
a function that prompts the user to enter a new contact. The
function then moves the contact to a public folder. It does its
job well, but with a hitch.

When the user hits the Save & Close button on the contact
form, the form saves but doesn't close. The Save & Close
button becomes disabled. The user can hit the X to close
the window and the function continues.

How do I make Save & Close do as it promises?

Here is a brief example of my code (C#):

// ol = Microsoft.Outlook.Interop.Outlook
// globalContactsFolder = a MAPIFolder object.

private void addContact()
{
if (app!=null)
ol.ContactItem newContact = (ol.ContactItem)
app.CreateItem(ol.OlItemType.olContactItem);
newContact.Display(true); // true=modal

newContact.Close(ol.OlInspectorClose.olSave);

if (newContact!=null)
{
ol.ContactItem contactForGlobal = (ol.ContactItem)
newContact.Copy();
contactForGlobal.Move(globalContactsFolder);
}

newContact.Delete();
//...
}

What can I do?

Thanks!!
Will
 
W

Will

So is there any way to pause execution until the contact item has been saved
and closed? Or, should I just continue clicking the X after saving?

Thanks for the response. I've read a lot of your material which has helped
me do good things with Outlook.

Will
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top