X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Send Outlook Contact With Picture, Office 2010    
post Aug 22 2018, 09:26 PM

Posts: 448
Joined: 26-March 13

I'd like to send Outlook contact with employee picture.
I am using late binding.
I used 'AddPicture(picture path)' method, but I couldn't add picture to 'Outlook contact'.

With olContact
                                  .FullName = Me.Parent![Contact Name]
                                    .FirstName = Nz(Me.Parent!GoesBy, "Name Needed")
                                    .LastName = Nz(Me.Parent!LastName, "Name Needed")
                                    .JobTitle = Nz(Me.Parent!JobTitle, "")
                                    .CompanyName = Nz(DLookup("Company", "tlkpCompany", "ID = " & Me.Parent!cboCompany), "")
                                  .FileAs = Me.Parent![Full Name]
                                    .Email1Address = Nz(Me.Parent!CompanyEmail, "")
                                    .BusinessTelephoneNumber = strBus
                                    .MobileTelephoneNumber = strMobile
                                    .HomeTelephoneNumber = strHome
                                    .HomeAddress = strAddress
                                   .Anniversary = Me.Parent!DOH
                                    .Birthday = Me.Parent!DOB
                                    .body = "Emergency Contact: " & vbNewLine & strEmergency
                                    .AddPicture = "picture path here "
                                    .Save 'use .Display if you wish the user to see the contact pop-up
                                End With

I also got errors on 'FullName', 'FileAs', and 'Anniversary'.
Why is that?

Please help me.
This post has been edited by winterolympic: Aug 22 2018, 10:00 PM
Go to the top of the page
post Aug 28 2018, 08:02 PM

UtterAccess VIP
Posts: 7,002
Joined: 30-June 11

The following works for me, a sample of working code (see http://www.devhut.net/2010/09/03/VBA-creat...utlook-contact/)

Function AddOlContact()
     Dim olApp                 As Object
     Dim olContact             As Object
     Const olContactItem = 2

     On Error GoTo Error_Handler

     Set olApp = CreateObject("Outlook.Application")
     Set olContact = olApp.CreateItem(olContactItem)

     With olContact
         .FirstName = "Daniel"
         .LastName = "Alba"
         .FullName = "Alba, Daniel"
         .FileAs = "D. Alba"
         .Anniversary = #7/22/1975#
         .JobTitle = ""
         .CompanyName = "MINI CARDA"
         .BusinessAddressStreet = "22 ClearPoint"
         .BusinessAddressCity = "Pointe-Claire"
         .BusinessAddressState = "Quebec"
         .BusinessAddressCountry = "Canada"
         .BusinessAddressPostalCode = "H9X 3A6"
         .BusinessTelephoneNumber = "(514) 488-0956"
         .BusinessFaxNumber = ""
         .Email1Address = "[email="mini@mini.com"]mini@mini.com[/email]"
         .MobileTelephoneNumber = ""
         .AddPicture ("C:\Users\ItsMe\Pictures\home-2955065_960_720.jpg")
         .Save    'use .Display if you wish the user to see the contact pop-up
     End With

     On Error Resume Next
     If Not olContact Is Nothing Then Set olContact = Nothing
     If Not olApp Is Nothing Then Set olApp = Nothing
     Exit Function

     MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
            "Error Number: " & Err.Number & vbCrLf & _
            "Error Source: AddOlContact" & vbCrLf & _
            "Error Description: " & Err.Description & _
            Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
            , vbOKOnly + vbCritical, "An Error has Occured!"
     Resume Error_Handler_Exit
End Function

I suspect some of your controls are passing nulls or the wrong type of values and thus errors.

Daniel Pineault (2010-2019 Microsoft MVP, UA VIP, EE Distinguished Expert 2018)
Professional Help: https://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: https://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc

All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page

Custom Search

RSSSearch   Top   Lo-Fi    9th December 2019 - 06:17 PM