Solved

Question on Outlook Automation

Posted on 2014-09-15
2
153 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 80

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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to Office 1 40
Find date of 2nd Thursday of each month 3 32
Copying from a network share 3 20
Convert VB web project to C# 3 32
This article will show, step by step, how to integrate R code into a R Sweave document
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
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.

740 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