Solved

Question on Outlook Automation

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SlingPlayer alternatives 1 35
DataGridView Events ? 3 37
Runtime Error 2 28
Help with Syntax 9 28
This article will show, step by step, how to integrate R code into a R Sweave document
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

895 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

19 Experts available now in Live!

Get 1:1 Help Now