使用Outlook联系人表单

问题描述:

我正在使用我的应用程序中的Outlook联系人表单,以允许用户创建新联系人。当用户保存联系人或关闭表单时,outlook的实例也会关闭。我如何保持展望结束,我没有完成对象,并且需要几秒钟才能打开另一个Outlook实例?使用Outlook联系人表单

Dim outlookApp as new Outlook.Application 
Dim newContact as New Outlook.ContactItem 
newContact = outlookApp.CreateItem(Outlook.OlItemType.olContactItem) 
newContact.Display(True) 

当其最后一个窗口(资源管理器或检查器)关闭时,即使存在对其对象的未完成引用,Outlook也会退出。

如果没有打开,请尝试保留对Outlook资源管理器的引用(它不必是可见的)。关闭我的头顶:

dim explorer as Outlook.Explorer 
... 
explorer = outlookApp.ActiveExplorer 
If (explorer Is Nothing) Then 
    session = outlookApp.GetNamespace("MAPI") 
    session.Logon 
    folder = session.GetDefaultFolder(olFolderInbox) 
    explorer = folder.GetExplorer 
End If