Solved

Question on Outlook Automation

Posted on 2014-09-15
2
151 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 79

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

786 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