PDA

View Full Version : Macro to be triggered every 5 minutes in Outlook



SJ1
10-14-2015, 12:17 PM
Hello,

I am new to VBA and I want to create a timer function which triggers a macro in Outlook (2013) , Can anyone help?


I have a working If statement which populates a user defined column if a specific value is chosen and the received time and the current time is more than 4 hours. The code in the column is only triggered when the option is classified.




What i would like is enable a timer to run this code every 5 minutes to check if this is still the same; so if it has been more than 4 hours then the column should be updated from No to Yes.




My code is





For Each msg In myCollection

If msg.UserProperties.Count > 0 Then
str2 = ""
For i1 = 1 To msg.UserProperties.Count
Set objProperty = msg.UserProperties(i1)
If objProperty.Name = "B" Then
str2 = objProperty.value(0)
End If
Next
End If

str4 = ""
If str2 = "A" Then
ReceivedTime = msg.ReceivedTime
WorkingTime = CurrentTime - ReceivedTime
If WorkingTime > (4 / 24) Then
str4 = "Yes"
Else
str4 = "No"
End If
End If
'MsgBox (str4)


'check if received time is > than 4 hours
If str2 = "Create Customer" Then
Set objProperty = msg.UserProperties.Add(udf(4), olKeywords)
objProperty.value = str4
msg.Save
End If




I appreciate any help!


Thank you