How to Restrict on NULL values

T

Terry Lindeman

The following code is supposed to retrieve all messages where Mileage does
not have the value "done".

Set cNewItems = InFolder.Items.Restrict("[Mileage] <> ""done""")

It retrieves messages with Mileage = "", but not messages with Mileage =
NULL. This seems to be a problem with Exchange moret than POP3. In SQL, I
could just say:

select * from message where mileage <> 'done' or mileage is null

Requesting Mileage = "" will get the blank ones, but not the null ones. Is
there a way to request null values in a Restrict clause?

Terry Lindeman
 
T

Terry Lindeman

Ken:

For a mail item, I assume this initialization to "" should be done in the
ItemAdd event for the InFolder. Are there any cases where that's not
possible? I've seen comments in newsgroups that items in the InFolder are
sometimes considered read-only.

Ken Slovak - said:
For the most part fields that are Null aren't even in the items, the
fields are only created in the item when a data value has been
assigned to it. I always init any fields I'm interested in as "" so I
don't run into that problem if I'm using a restriction.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Terry Lindeman said:
The following code is supposed to retrieve all messages where Mileage does
not have the value "done".

Set cNewItems = InFolder.Items.Restrict("[Mileage] <> ""done""")

It retrieves messages with Mileage = "", but not messages with Mileage =
NULL. This seems to be a problem with Exchange moret than POP3. In SQL, I
could just say:

select * from message where mileage <> 'done' or mileage is null

Requesting Mileage = "" will get the blank ones, but not the null ones. Is
there a way to request null values in a Restrict clause?

Terry Lindeman
 
T

Terry Lindeman

Ken:

This is an anti-spam application, so the idea is to avoid viewing the
messages..

ItemAdd is the perfect place for this, but I'm concerned that a POP3 user
may fire up Outlook and receive 100 spams all at once, so it sounds like
some of them might not get processed.

Do you have any data regarding how often this missed ItemAdd event might
occur? I guess a periodic timer event would be required.

Terry

Ken Slovak - said:
ItemAdd might not fire if there are too many items added at one time
to the folder. What I would use is the NewInspector event to catch a
new mail item being opened and use Inspector.CurrentItem to get the
mail item. Then I'd add the fields.

If the item wasn't opened but viewed in the preview pane you can use
Item.Read but you'd have to instantiate an Explorer.Selection
collection and when the selection changes instantiate items so
Item.Read would fire as an event you can handle.

If you want a property on all items whether they have been opened or
not you can use ItemAdd on the Items collection of the Inbox or you
can sweep the folder at intervals using a timer control to set the
intervals and check for the property you want on all the items in the
folder.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Terry Lindeman said:
Ken:

For a mail item, I assume this initialization to "" should be done in the
ItemAdd event for the InFolder. Are there any cases where that's not
possible? I've seen comments in newsgroups that items in the InFolder are
sometimes considered read-only.
 

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