Checking if what is selected is an email

  • Thread starter Thread starter noone
  • Start date Start date
N

noone

Is it possible to add a check to the code below to ensure
that what is/are selected is/are emails, and say, not something
from Contacts, or anywhere else ?

Set objApp = CreateObject("Outlook.Application")
Set objSelection = objApp.ActiveExplorer.Selection

For Each objItem In objSelection
SendKeys "^f" 'ctrl keys
SendKeys "#Unsolicited Email"
SendKeys "%s"
SendKeys "{DELETE}"
Next

Thanks.
 
Take a look at the Class property, which applies to every Outlook item. You can also use the TypeName() function or a TypeOf <object> Is expression.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
Back
Top