UtterAccess.com
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    
 
   
winterolympic
post Aug 22 2018, 09:26 PM
Post#1



Posts: 443
Joined: 26-March 13



Hi,
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'.

CODE
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
                                    '.Display
                                End With

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

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


UtterAccess VIP
Posts: 6,272
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/)

CODE
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

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

Error_Handler:
     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-2018 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://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    10th December 2018 - 10:11 AM