Submitted By: Kent Finkle

Adds a picture to the Jean Ross contact in Microsoft Outlook.

PowerShell
Edit|Remove
$comments = @'
Script name: Add-ContactPicture.ps1
Created on: Saturday, September 22, 2007
Author: Kent Finkle
Purpose: How can I use Windows Powershell to
Add a Picture To a Contact?
'@
# ----------------------------------------------------- 
function Release-Ref ($ref) { 
([System.Runtime.InteropServices.Marshal]::ReleaseComObject( 
[System.__ComObject]$ref) -gt 0) 
[System.GC]::Collect() 
[System.GC]::WaitForPendingFinalizers() 
} 
# ----------------------------------------------------- 
$olFolderContacts = 10

$o = new-object -comobject outlook.application
$n = $o.GetNamespace("MAPI")

$contacts = $n.GetDefaultFolder($olFolderContacts).Items

$contact = $contacts.Item("Jean Ross")
 
$a = $contact.AddPicture("C:\Scripts\BritneySpears.jpg")
$a = $contact.Save()
$a = $contact.Display()
 
$a = Release-Ref $contact
$a = Release-Ref $contacts
$a = Release-Ref $n
$a = Release-Ref $o