Rule: delete older than 2 weeks.

J

JohanW

Hello,
i would like to program a rule that deletes certain messages
(depending on the subject-title) to be deleted when they are older than
two weeks.
I cannot archive because i don't want this to apply to ALL my messages.

I'm struggling with the time issue in my code for the older than 2 weeks
part.

Anyone know how to solve this ??
I started with this example code from microsoft
http://msdn.microsoft.com/en-us/library/bb206765.aspx

Thank you.
 
K

Ken Slovak - [MVP - Outlook]

This is Outlook 2007 I assume? What language are you programming on? Is this
Outlook VBA or a COM addin or what? If this was Outlook VBA use the
DateDiff() function to subtract 14 days from Date to get to 2 weeks ago.

If that's too vague then post the part of the code you're stuck on so people
can see it an maybe help. Also provide any other relevant information.
 
J

JohanW

It's idd outlook 2007 and VBA.
I need something like the code below, but then for the date when the
email was send.. i cannot find out
the right code howto address the date (and hour?) the mail was send.


This code will set the condition for a rule. Here it will limit the
application
of the rule only to emails with recipient "Dan Wilson".
---
Set oFromCondition = oRule.Conditions.From
With oFromCondition
.Enabled = True
.Recipients.Add ("Dan Wilson")
.Recipients.ResolveAll
End With
 
K

Ken Slovak - [MVP - Outlook]

MailItem.ReceivedTime is when the email was received, MailItem.SentOn is
when it was sent out. Is that what you want?
 
J

JohanW

Yeah!
Looked for that for some time.
Thank you very much!



Ken Slovak - said:
MailItem.ReceivedTime is when the email was received, MailItem.SentOn is
when it was sent out. Is that what you want?
 

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