Hello Sue,
I'm very sorry I annoy you one more time. In spite of the
introduction, this message is about forms, so please read it all :°)
I want the messages I sent to be automatically moved to specific
folders. But rules just allow to copy them, and the copy is not marked
as read, wich is a big problem. I tried AutoRead but it's not free
:(. Since I created a custom form that I use as default mail form, I
though I could find a mean by this. Good thing, I had rules for
incoming messages already created. So I decided to automatically send
a copy to myself each time a send a mail. This copy matches the rules,
goes to the right folder and i just have to mark it as read.
When I send my e-mail, I wait 8s before lunching my function which
loops through the last received mails to find the one I just sent.
Everything is OK except one piece of code : i can't find the write
syntax for Item.Restric :
Function MarkAsRead()
Dim myItem
Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(6) '6 means inbox
Set myItems = myFolder.Items
Set myRestricItems = myItems.Restrict("[ReceivedTime] = '" & Now() -
8000 & "'")
' this was the pb. I want to restrict myItems to the one arrived in
the
' 8 last secondes
On Error Resume Next
For Each myItem In myItems
If myItem.To = "HUBERT Antoine" Then
myItem.UnRead = False
End If
Next
Once again thank you very much for your help
AnDOng
Sue Mosher [MVP-Outlook] - 19 Aug 2004 14:09 GMT
You need to omit the seconds element in your restriction string. See
http://www.outlookcode.com/d/finddate.htm
Your code below also omits an important statement:
MyItem.Save

Signature
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
> Hello Sue,
> I'm very sorry I annoy you one more time. In spite of the
[quoted text clipped - 31 lines]
> Once again thank you very much for your help
> AnDOng