MS Outlook custom rule help
Hello all,
I am trying to figure out a way to create a custom rule in Outlook to display an alert/notification or sound based on a future time after a specific e-mail arrives. Listed below is what I'm trying for:
1. An email arrives with a subject keyword "severity - 3"
2. This triggers the rule to send a notification/alert or sound 5 hours from when that e-mail arrived.
I have searched all over without having much luck in this. Can someone please help?
Thank you,
Mike
Re: MS Outlook custom rule help
Welcome to the forums. :wave:
What version of Office are you using?
Re: MS Outlook custom rule help
Thanks :)
I'm using Office 2007
Re: MS Outlook custom rule help
Have you gone through The Rules and Alerts Wizard in Outlook?
Re: MS Outlook custom rule help
Yes, I have gone through it quite extensively. The only way I figure this could be done easily would be to create a custom VBA macro to have Outlook take the email, create a task using the subject line from the email and set a reminder trigger for 5 hours from the time that task was created. However, I do not know anything about VBA at all.
Re: MS Outlook custom rule help
In that case, you might want to check out some of the third party add-ins that have been created for Outlook.
Here are some links that might be useful for you.
Outlook Custom Add-ins
Re: MS Outlook custom rule help
Thanks for the suggestions, Hack. I found a couple websites that had some examples I could relate to, and was able to piece together the code I needed, which works great.
Code:
Sub ProcessMailItemIntoTask(Item As Outlook.MailItem)
Dim strTaskName As String
strTaskName = Trim(Item.Subject)
If Len(strTaskName) < 1 Then
' No subject - use the first line of the body
strTaskName = Trim(Item.Body)
Dim intCrLfPos As Integer
intCrLfPos = InStr(1, strTaskName, Constants.vbCrLf, vbTextCompare)
If intCrLfPos > 0 Then
strTaskName = Trim(Left(strTaskName, intCrLfPos - 1))
End If
End If
' Create the task
Dim objTask As Outlook.TaskItem
Set objTask = Application.CreateItem(olTaskItem)
objTask.Subject = strTaskName
objTask.StartDate = Item.ReceivedTime
objTask.ReminderSet = True
objTask.ReminderTime = DateAdd("h", 5, Now)
objTask.Save
Set objTask = Nothing
End Sub
This script takes any e-mail and automatically creates a task using the same subject line, or first line in the body if there are no subject, and creates a reminder for 5-hours from the time that email arrived.
Re: MS Outlook custom rule help
Actually, if anyone knows how I could incorporate that script to only count the hours between 8am-5pm, that would be great. Not sure if that is even possible though.
Re: MS Outlook custom rule help
Ok, this is very odd. This code worked great for one day. After I rebooted my computer and opened up Outlook again, it does not work anymore. I verified the rule is still active and nothing has changed in the script. There aren't any error messages either. It just stopped working. Any ideas?
vb Code:
Sub ProcessMailItemIntoTask(Item As Outlook.MailItem)
Dim strTaskName As String
strTaskName = Trim(Item.Subject)
If Len(strTaskName) < 1 Then
' No subject - use the first line of the body
strTaskName = Trim(Item.Body)
Dim intCrLfPos As Integer
intCrLfPos = InStr(1, strTaskName, Constants.vbCrLf, vbTextCompare)
If intCrLfPos > 0 Then
strTaskName = Trim(Left(strTaskName, intCrLfPos - 1))
End If
End If
' Create the task
Dim objTask As Outlook.TaskItem
Set objTask = Application.CreateItem(olTaskItem)
objTask.Subject = strTaskName
objTask.StartDate = Item.ReceivedTime
objTask.ReminderSet = True
objTask.ReminderTime = DateAdd("h", 5, Now)
objTask.Save
Set objTask = Nothing
End Sub