email address not being deleted

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?
 

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