PDA

View Full Version : Move Email After a Few Seconds



lloughridge
02-08-2011, 06:23 PM
Hello,
I am looking for a way to have rule like: After the message arrives move it to the 2011 folder, but for xx seconds before moving each email.

gcomyn
02-09-2011, 10:12 AM
What are the criteria that you would be using for this 'rule'? I don't think that Outlook has a delay function for the rules, so you would probably have to use vba code to do what you want. (which can be [and probably has been] done, with some work).

Have you searched the web for something like this, or even searched here on this site?

GComyn
:sleuth:

IBihy
02-09-2011, 12:09 PM
Hello,

the cheapest timer I know, is a loop counting from, say 1 to one million, in the loop do an operation, like accumulating a number. Put that at the top of your mail fetcher. You may have to dawdle a bit with the UNTIL value.
This technique used to work on the pre 1 GHz processors.

A mite more elegant is the Wait method of the Application object. It's available in Excel, and I dare to predict, it's in Outlook as well.

Have fun testing.
Isabella
Const FROM = 1
Const UNTIL = 1000000
Const WHATEVER = 1
Dim lngCt as Long
Dim lngAddUp as Long
lngAddUp = 0
For lngCt = FROM to UNTIL
lngAddUp = lngAddUp + WHATEVER
Next lngFrom
'.... the remainder of the mail fetcher is here

JP2112
02-10-2011, 02:15 PM
I'm afraid Outlook has no Wait Method. Here are the methods I've found.

Sleep API

' put this at the top of your module
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
' use this command to pause
Sleep (5000) ' Waits for 5 seconds


Timer Function (from VBA Help)
Dim PauseTime, Start, Finish, TotalTime
If (MsgBox("Press Yes to pause for 5 seconds", 4)) = vbYes Then
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox "Paused for " & TotalTime & " seconds"
Else
End
End If