Outlook 2003 Contacts & Powershell

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?
 
B

Brian Tillman [MVP - Outlook]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top