We help IT Professionals succeed at work.

VB.Net creating Contact in Outlook

475 Views
Last Modified: 2017-04-11
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 = "abc@hotmail.com"
        NewContact.Email2Address = "abc@live.com"
        NewContact.MailingAddress = "NewDelhi India"
        NewContact.Subject = "Contact crated from vb.net"
        NewContact.JobTitle = "Engineer"

        NewContact.Save()


        outApplication = Nothing
        outNamSpace = Nothing
        NewContact = Nothing

    End Sub

Open in new window

Comment
Watch Question

CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions