A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Apply Photo to Contact



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 17th 06, 11:53 AM posted to microsoft.public.outlook.program_vba
Programatix
external usenet poster
 
Posts: 4
Default Apply Photo to Contact

Hi,

Is there a way to apply photo to a contact via VBA?

Thanks.


  #2  
Old August 17th 06, 03:35 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Apply Photo to Contact

Outlook 2003? Use the ContactItem.HasPicture Boolean to see if a picture is
there for the contact. Use the AddPicture(path) method to add a picture to
the contact.

For earlier versions of Outlook you'd need to add a custom control such as a
picturebox to add a picture.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Programatix" wrote in message
...
Hi,

Is there a way to apply photo to a contact via VBA?

Thanks.


  #3  
Old August 17th 06, 04:01 PM posted to microsoft.public.outlook.program_vba
Programatix
external usenet poster
 
Posts: 4
Default Apply Photo to Contact

Thanks for the quick respond.

While waiting for the respond from the newsgroup, I did some research using
the Office Help and come out with the following code to add photo for each
contacts. The image file should be named like the contact's name.

Hope it is useful to anyone out there.

Public Sub UpdateContactPhoto(ContactPhotoPath As String)
Dim myOlApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myContacts As Outlook.Items
Dim myItems As Outlook.Items
Dim myItem As Object
Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts).Ite ms

Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
For Each myItem In myContacts
If (myItem.Class = olContact) Then
Dim myContact As Outlook.ContactItem
Set myContact = myItem

Dim strPhoto As String
strPhoto = ContactPhotoPath & myContact.FileAs & ".jpg"
If fs.FileExists(strPhoto) Then
myContact.AddPicture strPhoto
myContact.Save
End If
End If
Next
End Sub

"Ken Slovak - [MVP - Outlook]" wrote in message
...
Outlook 2003? Use the ContactItem.HasPicture Boolean to see if a picture
is there for the contact. Use the AddPicture(path) method to add a picture
to the contact.

For earlier versions of Outlook you'd need to add a custom control such as
a picturebox to add a picture.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Programatix" wrote in message
...
Hi,

Is there a way to apply photo to a contact via VBA?

Thanks.




 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Apply Contact's Photo via VBA or DotNet? Programatix Outlook - General Queries 3 August 26th 06 09:04 PM
how do I apply a form to one Contact? don Outlook - Using Forms 1 July 5th 06 07:40 PM
how to apply new contact form to existing forms Nick Cumberbatch Outlook - Using Contacts 1 July 2nd 06 06:45 PM
Paste a photo JOHN SMITH Outlook Express 0 June 5th 06 09:02 PM
Changing Contact Info in One Folder - How to apply in other folder atbioteach Outlook - Using Contacts 1 February 3rd 06 01:27 AM


All times are GMT +1. The time now is 09:20 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.