Outlook 2003 Contacts & Powershell

  • Thread starter Thread starter sluice
  • Start date Start date
S

sluice

I am trying to delete all the contacts in my "Agencies" folder which have no
email1address, as follows:

$outlook = new-object -comobject "Outlook.Application"
$session=$outlook.Session
$agencies=$outlook.GetNamespace("MAPI").PickFolder()# Get the Agencies
folder object
foreach ($agency in $agencies.Items ){
$email=$agency.Email1Address
if ($email -eq ""){
$agency.companyname
$agency.delete
}}

Although if $email = "" the company name is displayed, indicating this item
has no email address, the delete function doesn't delete the agency. Any
suggestions why not?
 
I am trying to delete all the contacts in my "Agencies" folder which have
no
email1address, as follows:

$outlook = new-object -comobject "Outlook.Application"
$session=$outlook.Session
$agencies=$outlook.GetNamespace("MAPI").PickFolder()# Get the Agencies
folder object
foreach ($agency in $agencies.Items ){
$email=$agency.Email1Address
if ($email -eq ""){
$agency.companyname
$agency.delete
}}

Although if $email = "" the company name is displayed, indicating this
item
has no email address, the delete function doesn't delete the agency. Any
suggestions why not?

microsoft.public.outlook.program_vba may be a better newsgroup and that's
where the programmers visit.
 
Back
Top