Hi
Hopefully someone can help me with an Outlook/VBA issue, or at least point me in the correct direction.
Currently my work PC receives all the e-mail for our helpdesk, and as such is left on 24/7. At the moment I have a fairly long list of individual rules set up to move the e-mails to seperate folders based on either originating email address, or domain (depending on company it is received from). I also have a filter for SPAM e-mails pre-marked by our e-mail supplier.
Outside of office hours, we have a duty manager who is on-call, and used to carry around a laptop and mobile, but we have recently swapped to an XDA.
What I would like to do is to forward a copy of any e-mails received out of office hours, or on a Sat/Sun to a seperate e-mail address (and set this up on the XDA). So, when an e-mail is received, the day/time is checked : if sat/sun then forward a copy, or if mon-fri then if time is outwith 9-5 then forward a copy.
Would this work ok on it's own, or would I be better to control all filtering from VBA rather than some VBA and some Rules?
I've done some searching on Google for hints, and have done some VBA in the past (just never with Outlook).
I'd appreciate it if someone could point me in the right direction, or help me out a bit. The currecnt code fragment I'm working from is:
Public WithEvents myOlItems As Outlook.Items
Public Sub Application_Startup()
' Reference the items in the Inbox. Because myOlItems is declared
' "WithEvents" the ItemAdd event will fire below.
Set myOlItems = Outlook.Session.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub myOlItems_ItemAdd(ByVal Item As Object)
' If it's currently not between 9:00 A.M. and 5:00 P.M.
If Time() < #9:00:00 AM# Or Time() > #5:00:00 PM# Then
' Check to make sure it is an Outlook mail message, otherwise
' subsequent code will probably fail depending on what type
' of item it is.
If TypeName(Item) = "MailItem" Then
' Forward the item just received
Set myForward = Item.Forward
' Address the message
myForward.Recipients.Add "dutymanager@domain"
' Send it
myForward.Send
End If
End If
End Sub
This code is checking the Inbox, but I already filter 95% of email, so would this pickup emails before they filter to a different folder? Do I need to change this to check all folder (if so, how), or as I said should I just swap to VBA entirely?
Regards,
Chris
Hopefully someone can help me with an Outlook/VBA issue, or at least point me in the correct direction.
Currently my work PC receives all the e-mail for our helpdesk, and as such is left on 24/7. At the moment I have a fairly long list of individual rules set up to move the e-mails to seperate folders based on either originating email address, or domain (depending on company it is received from). I also have a filter for SPAM e-mails pre-marked by our e-mail supplier.
Outside of office hours, we have a duty manager who is on-call, and used to carry around a laptop and mobile, but we have recently swapped to an XDA.
What I would like to do is to forward a copy of any e-mails received out of office hours, or on a Sat/Sun to a seperate e-mail address (and set this up on the XDA). So, when an e-mail is received, the day/time is checked : if sat/sun then forward a copy, or if mon-fri then if time is outwith 9-5 then forward a copy.
Would this work ok on it's own, or would I be better to control all filtering from VBA rather than some VBA and some Rules?
I've done some searching on Google for hints, and have done some VBA in the past (just never with Outlook).
I'd appreciate it if someone could point me in the right direction, or help me out a bit. The currecnt code fragment I'm working from is:
Public WithEvents myOlItems As Outlook.Items
Public Sub Application_Startup()
' Reference the items in the Inbox. Because myOlItems is declared
' "WithEvents" the ItemAdd event will fire below.
Set myOlItems = Outlook.Session.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub myOlItems_ItemAdd(ByVal Item As Object)
' If it's currently not between 9:00 A.M. and 5:00 P.M.
If Time() < #9:00:00 AM# Or Time() > #5:00:00 PM# Then
' Check to make sure it is an Outlook mail message, otherwise
' subsequent code will probably fail depending on what type
' of item it is.
If TypeName(Item) = "MailItem" Then
' Forward the item just received
Set myForward = Item.Forward
' Address the message
myForward.Recipients.Add "dutymanager@domain"
' Send it
myForward.Send
End If
End If
End Sub
This code is checking the Inbox, but I already filter 95% of email, so would this pickup emails before they filter to a different folder? Do I need to change this to check all folder (if so, how), or as I said should I just swap to VBA entirely?
Regards,
Chris