Results 1 to 2 of 2
  1. #1
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402

    Outlook late binding to create a new contact

    Hi everyone

    i currently use the code below as early binding to create a contact in out look when a button on my form is pressed



    Code:
    Private Sub OutlookContact_Click()
    Dim strInput   As String
    Dim rsdbase    As Database
    Dim rstemp     As Recordset
    Dim olns       As NameSpace
    Dim cf         As MAPIFolder
    Dim c          As ContactItem
    Dim ol         As New Outlook.Application
    
        Set olns = ol.GetNamespace("MAPI")
        Set cf = olns.GetDefaultFolder(olFolderContacts)
        Set rsdbase = CurrentDb
        Set rstemp = rsdbase.OpenRecordset("qryCustomersDetails")
        With rstemp
    
            Set c = ol.CreateItem(olContactItem)
            c.MessageClass = "IPM.Contact"
            Set c = cf.Items.Add
            ' Me.CustomerID = ![CustomerID]
            If Me.Business_Name <> "" Then c.CompanyName = Me.Business_Name
            If Me.First_Name <> "" Then c.firstname = Me.First_Name
            If Me.Last_Name <> "" Then c.LastName = Me.Last_Name
            If Me.[E-Mail Address] <> "" Then c.Email1Address = Me.[E-Mail Address]
            If Me.Phone_Number <> "" Then c.HomeTelephoneNumber = Me.Phone_Number
            If Me.Street <> "" Then c.HomeAddressStreet = Me.Street
            If Me.Town <> "" Then c.HomeAddressCity = Me.Town
            If Me.County <> "" Then c.HomeAddressState = Me.County
            If Me.Post_Code <> "" Then c.HomeAddressPostalCode = Me.Post_Code
            If Me.Web_Site <> "" Then c.WebPage = Me.Web_Site
    
            c.Save
    
        End With
        Set ol = Nothing
        Set olns = Nothing
        Me.Added_to_Outlook = True
        MsgBox "All Contacts Successfully Exported to Outlook!"
    
        Me.OutlookContact.Visible = True
        Me.Requery
    end sub
    I am totally stuck on changing this to Late binding so that i can get ride of the references, any help would be most gratefully received

    many thanks in advance

    Steve

  2. #2
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi All

    i have managed to solve it with help from this site
    http://www.devhut.net/2010/09/03/vba...tlook-contact/

    this is the code that i used

    Code:
    Const olContactItem = 2
        Dim olApp As Object
        Dim Ctct As Object
        Dim olcontact As Object
        
        Set olApp = CreateObject("Outlook.Application")
        Set olcontact = olApp.CreateItem(olContactItem)
     
        With olcontact
            .FirstName = Me.First_Name
            .LastName = Me.Last_Name
            '.JobTitle = ""
            .CompanyName = Me.Business_Name
            .BusinessAddressStreet = Me.Street
            .BusinessAddressCity = Me.Town
            .BusinessAddressState = Me.County
           '.BusinessAddressCountry = me.County
            .BusinessAddressPostalCode = Me.Post_Code
            .BusinessTelephoneNumber = Me.Phone_Number
            .BusinessFaxNumber = ""
            .Email1Address = Me.[E-Mail Address]
            .MobileTelephoneNumber = ""
            .Save 'use .Display if you wish the user to see the contact pop-up
    
      End With
    
        On Error Resume Next
        Set olcontact = Nothing
        Set olApp = Nothing
    Steve

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 08-21-2016, 04:57 PM
  2. Using Late Binding in creating custom ribbons
    By Demerit in forum Programming
    Replies: 2
    Last Post: 08-25-2015, 04:17 PM
  3. Late Binding Outlook Tasks and Appointments
    By sstiebinger in forum Programming
    Replies: 2
    Last Post: 08-21-2015, 02:20 PM
  4. send outlook email with late binding
    By markjkubicki in forum Programming
    Replies: 3
    Last Post: 01-24-2014, 09:39 AM
  5. How do I achieve late binding on a Chart?
    By RocketMonkey in forum Forms
    Replies: 1
    Last Post: 02-12-2013, 02:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums