Checking if what is selected is an email

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.
 
S

Sue Mosher [MVP]

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
 

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