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