Solved

Question on Outlook Automation

Posted on 2014-09-15
2
147 Views
Last Modified: 2014-09-15
Experts, I am using the following code to access Outlook contacts for an application I am working on. At the very end when I quit the application if the user has Outlook open it closes the application. I thought that I was creating a new instance and closing it. Is there another way I should be doing this?

        Dim outlookApp As Outlook.Application = New Outlook.Application
        'Dim oNS As Outlook.NameSpace = outlookApp.Session
        Dim oNS As Outlook.NameSpace = outlookApp.GetNamespace("mapi")
        Dim oContacts As Outlook.MAPIFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
        Dim oItems As Outlook.Items = oContacts.Items
        Dim oContact As Outlook.ContactItem = Nothing

        For Each contactItem As Outlook.ContactItem In oContacts.Items
            Debug.WriteLine(contactItem.FullName)
        Next

        outlookApp.Quit()
        outlookApp = Nothing

Open in new window

0
Comment
Question by:Basicfarmer
2 Comments
 
LVL 78

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
ID: 40324276
only 1 instance of outlook can run at a time
0
 

Author Closing Comment

by:Basicfarmer
ID: 40324492
Thanks...
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now