troubleshooting Question

VB.Net creating Contact in Outlook

Avatar of AlexPonnath
AlexPonnathFlag for United States of America asked on
Microsoft ApplicationsVisual Basic.NET.NET ProgrammingOutlookEmail Clients
1 Comment1 Solution486 ViewsLast Modified:
I have a need to be able to create a Contact in a Users Outlook Address book. Here is some more info, some users have more then one  Email account which means multiple address books. So here is my question, how do I save to the default address book ? Is there a way to get a list of address books for a user and have him chose where to save. Also I have the below sample code but when I run it it does not throw an error nor do I find the contact in any of my address books

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        ' Create an Outlook application.
        Dim outApplication As Outlook.Application = New Outlook.Application()

        ' Get the namespace and the logon.
        Dim outNamSpace As Outlook.NameSpace = outApplication.GetNamespace("MAPI")

        ' Create a new contact item.
        Dim NewContact As Outlook.ContactItem = outApplication.CreateItem(Outlook.OlItemType.olContactItem)

        ' Set some common properties.
        NewContact.FirstName = "Author"
        NewContact.FullName = "Author Code"
        NewContact.Title = "Client"
        NewContact.Birthday = Convert.ToDateTime("5/4/1969")
        NewContact.CompanyName = "AuthorCode"
        NewContact.Department = "Development"
        NewContact.Body = "Sample"
        NewContact.FileAs = "Authorcode"
        NewContact.Email1Address = ""
        NewContact.Email2Address = ""
        NewContact.MailingAddress = "NewDelhi India"
        NewContact.Subject = "Contact crated from"
        NewContact.JobTitle = "Engineer"


        outApplication = Nothing
        outNamSpace = Nothing
        NewContact = Nothing

    End Sub

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros