| Home | Forums | Reviews | Articles | Register |
![]() |
| Thread Tools | Rate Thread |
|
|
|
| |
|
Josh Skelton
Guest
Posts: n/a
|
Below is a VBA script, a macro, that will forward emails received in your Outlook Inbox to an external email address. I needed this to forward work emails from Outlook to my Blackberry phone and it works.
To use it: 1. Start Outlook 2. Click Tools->Macro->Visual Basic Editor 3. If not already expanded, expand Microsoft Outlook Objects in the Project pane, then click on "ThisOutlookSession" 4. Copy the script below 5. Paste the script into the right-hand pane of the VB Editor 6. Edit the script making the changes as per the comments I included in the code 7. Click the diskette icon on the toolbar to save the changes 8. Close the VB Editor 9. Click Tools->Macro->Security 10. Set Security Level to Medium 11. Close Outlook 12. Start Outlook 13. A dialog-box will appear telling you the ThisOutlookSession contains macros and asking if you want to enable them. Say yes. 14. Test the macro 15. When the macro runs Outlook will present you with another dialog-box advising that a program is trying to access your mailbox and asking if you want to allow it to. Say yes. 16. If a message is received in the mailbox, and if the time is currently between the times you set, then the message will be forwarded to the designated email address. Otherwise, nothing will happen. 17. Once you've verified that the macro works as expected, then you need to sign the macro to avoid having Outlook security warn you each time the macro runs. 'START CODE Private WithEvents objInboxItems As Items Private Sub Application_Startup() Dim objNS As NameSpace Set objNS = Application.GetNamespace("MAPI") ' instantiate Items collections for folders we want to monitor Set objInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items Set objNS = Nothing End Sub Private Sub Application_Quit() ' disassociate global objects declared WithEvents Set objInboxItems = Nothing End Sub Private Sub objInboxItems_ItemAdd(ByVal Item As Object) Dim olItems As Items, _ olItem As Object, _ olMailItem As MailItem, _ olAttachmentItem As Attachment, _ bolTimeMatch As Boolean Set olItems = objInboxItems.Restrict("[Unread] = True") For Each olItem In olItems If olItem.Class = olMail Then Set olMailItem = olItem 'Change the times on the next line to those you want to use bolTimeMatch = (Time >= #4:00:00 PM#) And (Time <= #8:30:00 AM#) If bolTimeMatch Then Dim objMail As Outlook.MailItem Set objItem = olMailItem Set objMail = objItem.Forward 'PUT THE EXTERNAL EMAIL ADDRESS YOU WANT TO USE ON THE NEXT LINE objMail.To = "(E-Mail Removed)" objMail.Send Set objItem = Nothing Set objMail = Nothing End If End If Next End Sub Function IsNothing(Obj) If TypeName(Obj) = "Nothing" Then IsNothing = True Else IsNothing = False End If End Function 'END CODE > On Monday, January 18, 2010 1:06 PM J_Nettles wrote: > Afternoon All: > > I am not sure if this can be done or not... we want to auto forward by rule > email messages during a specific time period... most specifically after > hours... is it possible to create a rule that would forward emails with a > specific criteria during a specific set of hours? > > Thanks > -- > J_Nettles > Submitted via EggHeadCafe > SQL Server CLR Stored Procedures for External Access > http://www.eggheadcafe.com/tutorials...al-access.aspx |
|
||
|
||||
|
Josh Skelton
Guest
Posts: n/a
|
Below is a VBA script, a macro, that will forward emails received in your Outlook Inbox to an external email address. I needed this to forward work emails from Outlook to my Blackberry phone and it works.
To use it: 1. Start Outlook 2. Click Tools->Macro->Visual Basic Editor 3. If not already expanded, expand Microsoft Outlook Objects in the Project pane, then click on "ThisOutlookSession" 4. Copy the script below 5. Paste the script into the right-hand pane of the VB Editor 6. Edit the script making the changes as per the comments I included in the code 7. Click the diskette icon on the toolbar to save the changes 8. Close the VB Editor 9. Click Tools->Macro->Security 10. Set Security Level to Medium 11. Close Outlook 12. Start Outlook 13. A dialog-box will appear telling you the ThisOutlookSession contains macros and asking if you want to enable them. Say yes. 14. Test the macro 15. When the macro runs Outlook will present you with another dialog-box advising that a program is trying to access your mailbox and asking if you want to allow it to. Say yes. 16. If a message is received in the mailbox, and if the time is currently between the times you set, then the message will be forwarded to the designated email address. Otherwise, nothing will happen. 17. Once you've verified that the macro works as expected, then you need to sign the macro to avoid having Outlook security warn you each time the macro runs. 'START CODE Private WithEvents objInboxItems As Items Private Sub Application_Startup() Dim objNS As NameSpace Set objNS = Application.GetNamespace("MAPI") ' instantiate Items collections for folders we want to monitor Set objInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items Set objNS = Nothing End Sub Private Sub Application_Quit() ' disassociate global objects declared WithEvents Set objInboxItems = Nothing End Sub Private Sub objInboxItems_ItemAdd(ByVal Item As Object) Dim olItems As Items, _ olItem As Object, _ olMailItem As MailItem, _ olAttachmentItem As Attachment, _ bolTimeMatch As Boolean Set olItems = objInboxItems.Restrict("[Unread] = True") For Each olItem In olItems If olItem.Class = olMail Then Set olMailItem = olItem 'Change the times on the next line to those you want to use bolTimeMatch = (Time >= #4:00:00 PM#) And (Time <= #8:30:00 AM#) If bolTimeMatch Then Dim objMail As Outlook.MailItem Set objItem = olMailItem Set objMail = objItem.Forward 'PUT THE EXTERNAL EMAIL ADDRESS YOU WANT TO USE ON THE NEXT LINE objMail.To = "(E-Mail Removed)" objMail.Send Set objItem = Nothing Set objMail = Nothing End If End If Next End Sub Function IsNothing(Obj) If TypeName(Obj) = "Nothing" Then IsNothing = True Else IsNothing = False End If End Function 'END CODE > On Monday, January 18, 2010 1:06 PM J_Nettles wrote: > Afternoon All: > > I am not sure if this can be done or not... we want to auto forward by rule > email messages during a specific time period... most specifically after > hours... is it possible to create a rule that would forward emails with a > specific criteria during a specific set of hours? > > Thanks > -- > J_Nettles >> On Tuesday, March 08, 2011 4:19 PM Josh Skelton wrote: >> Below is a VBA script, a macro, that will forward emails received in your Outlook Inbox to an external email address. I needed this to forward work emails from Outlook to my Blackberry phone and it works. >> >> >> >> To use it: >> >> 1. Start Outlook >> >> 2. Click Tools->Macro->Visual Basic Editor >> >> 3. If not already expanded, expand Microsoft Outlook Objects in the Project pane, then click on "ThisOutlookSession" >> >> 4. Copy the script below >> >> 5. Paste the script into the right-hand pane of the VB Editor >> >> 6. Edit the script making the changes as per the comments I included in the code >> >> 7. Click the diskette icon on the toolbar to save the changes >> >> 8. Close the VB Editor >> >> 9. Click Tools->Macro->Security >> >> 10. Set Security Level to Medium >> >> 11. Close Outlook >> >> 12. Start Outlook >> >> 13. A dialog-box will appear telling you the ThisOutlookSession contains macros and asking if you want to enable them. Say yes. >> >> 14. Test the macro >> >> 15. When the macro runs Outlook will present you with another dialog-box advising that a program is trying to access your mailbox and asking if you want to allow it to. Say yes. >> >> 16. If a message is received in the mailbox, and if the time is currently between the times you set, then the message will be forwarded to the designated email address. Otherwise, nothing will happen. >> >> 17. Once you've verified that the macro works as expected, then you need to sign the macro to avoid having Outlook security warn you each time the macro runs. >> >> >> >> 'START CODE >> >> Private WithEvents objInboxItems As Items >> >> >> >> Private Sub Application_Startup() >> >> Dim objNS As NameSpace >> >> Set objNS = Application.GetNamespace("MAPI") >> >> ' instantiate Items collections for folders we want to monitor >> >> Set objInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items >> >> Set objNS = Nothing >> >> End Sub >> >> >> >> Private Sub Application_Quit() >> >> ' disassociate global objects declared WithEvents >> >> Set objInboxItems = Nothing >> >> End Sub >> >> >> >> Private Sub objInboxItems_ItemAdd(ByVal Item As Object) >> >> Dim olItems As Items, _ >> >> olItem As Object, _ >> >> olMailItem As MailItem, _ >> >> olAttachmentItem As Attachment, _ >> >> bolTimeMatch As Boolean >> >> Set olItems = objInboxItems.Restrict("[Unread] = True") >> >> For Each olItem In olItems >> >> If olItem.Class = olMail Then >> >> Set olMailItem = olItem >> >> 'Change the times on the next line to those you want to use >> >> bolTimeMatch = (Time >= #4:00:00 PM#) And (Time <= #8:30:00 AM#) >> >> If bolTimeMatch Then >> >> Dim objMail As Outlook.MailItem >> >> Set objItem = olMailItem >> >> Set objMail = objItem.Forward >> >> 'PUT THE EXTERNAL EMAIL ADDRESS YOU WANT TO USE ON THE NEXT LINE >> >> objMail.To = "(E-Mail Removed)" >> >> objMail.Send >> >> Set objItem = Nothing >> >> Set objMail = Nothing >> >> End If >> >> End If >> >> Next >> >> End Sub >> >> >> >> Function IsNothing(Obj) >> >> If TypeName(Obj) = "Nothing" Then >> >> IsNothing = True >> >> Else >> >> IsNothing = False >> >> End If >> >> End Function >> >> 'END CODE >> Submitted via EggHeadCafe >> LINQ executed in Parallel (PLINQ) >> http://www.eggheadcafe.com/tutorials...lel-plinq.aspx |
|
||
|
||||
|
Josh Skelton
Guest
Posts: n/a
|
Below is a VBA script, a macro, that will forward emails received in your Outlook Inbox to an external email address. I needed this to forward work emails from Outlook to my Blackberry phone and it works.
To use it: 1. Start Outlook 2. Click Tools->Macro->Visual Basic Editor 3. If not already expanded, expand Microsoft Outlook Objects in the Project pane, then click on "ThisOutlookSession" 4. Copy the script below 5. Paste the script into the right-hand pane of the VB Editor 6. Edit the script making the changes as per the comments I included in the code 7. Click the diskette icon on the toolbar to save the changes 8. Close the VB Editor 9. Click Tools->Macro->Security 10. Set Security Level to Medium 11. Close Outlook 12. Start Outlook 13. A dialog-box will appear telling you the ThisOutlookSession contains macros and asking if you want to enable them. Say yes. 14. Test the macro 15. When the macro runs Outlook will present you with another dialog-box advising that a program is trying to access your mailbox and asking if you want to allow it to. Say yes. 16. If a message is received in the mailbox, and if the time is currently between the times you set, then the message will be forwarded to the designated email address. Otherwise, nothing will happen. 17. Once you've verified that the macro works as expected, then you need to sign the macro to avoid having Outlook security warn you each time the macro runs. 'START CODE Private WithEvents objInboxItems As Items Private Sub Application_Startup() Dim objNS As NameSpace Set objNS = Application.GetNamespace("MAPI") ' instantiate Items collections for folders we want to monitor Set objInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items Set objNS = Nothing End Sub Private Sub Application_Quit() ' disassociate global objects declared WithEvents Set objInboxItems = Nothing End Sub Private Sub objInboxItems_ItemAdd(ByVal Item As Object) Dim olItems As Items, _ olItem As Object, _ olMailItem As MailItem, _ olAttachmentItem As Attachment, _ bolTimeMatch As Boolean Set olItems = objInboxItems.Restrict("[Unread] = True") For Each olItem In olItems If olItem.Class = olMail Then Set olMailItem = olItem 'Change the times on the next line to those you want to use bolTimeMatch = (Time >= #4:00:00 PM#) And (Time <= #8:30:00 AM#) If bolTimeMatch Then Dim objMail As Outlook.MailItem Set objItem = olMailItem Set objMail = objItem.Forward 'PUT THE EXTERNAL EMAIL ADDRESS YOU WANT TO USE ON THE NEXT LINE objMail.To = "(E-Mail Removed)" objMail.Send Set objItem = Nothing Set objMail = Nothing End If End If Next End Sub Function IsNothing(Obj) If TypeName(Obj) = "Nothing" Then IsNothing = True Else IsNothing = False End If End Function 'END CODE > On Monday, January 18, 2010 1:06 PM J_Nettles wrote: > Afternoon All: > > I am not sure if this can be done or not... we want to auto forward by rule > email messages during a specific time period... most specifically after > hours... is it possible to create a rule that would forward emails with a > specific criteria during a specific set of hours? > > Thanks > -- > J_Nettles >> On Tuesday, March 08, 2011 4:19 PM Josh Skelton wrote: >> Below is a VBA script, a macro, that will forward emails received in your Outlook Inbox to an external email address. I needed this to forward work emails from Outlook to my Blackberry phone and it works. >> >> >> >> To use it: >> >> 1. Start Outlook >> >> 2. Click Tools->Macro->Visual Basic Editor >> >> 3. If not already expanded, expand Microsoft Outlook Objects in the Project pane, then click on "ThisOutlookSession" >> >> 4. Copy the script below >> >> 5. Paste the script into the right-hand pane of the VB Editor >> >> 6. Edit the script making the changes as per the comments I included in the code >> >> 7. Click the diskette icon on the toolbar to save the changes >> >> 8. Close the VB Editor >> >> 9. Click Tools->Macro->Security >> >> 10. Set Security Level to Medium >> >> 11. Close Outlook >> >> 12. Start Outlook >> >> 13. A dialog-box will appear telling you the ThisOutlookSession contains macros and asking if you want to enable them. Say yes. >> >> 14. Test the macro >> >> 15. When the macro runs Outlook will present you with another dialog-box advising that a program is trying to access your mailbox and asking if you want to allow it to. Say yes. >> >> 16. If a message is received in the mailbox, and if the time is currently between the times you set, then the message will be forwarded to the designated email address. Otherwise, nothing will happen. >> >> 17. Once you've verified that the macro works as expected, then you need to sign the macro to avoid having Outlook security warn you each time the macro runs. >> >> >> >> 'START CODE >> >> Private WithEvents objInboxItems As Items >> >> >> >> Private Sub Application_Startup() >> >> Dim objNS As NameSpace >> >> Set objNS = Application.GetNamespace("MAPI") >> >> ' instantiate Items collections for folders we want to monitor >> >> Set objInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items >> >> Set objNS = Nothing >> >> End Sub >> >> >> >> Private Sub Application_Quit() >> >> ' disassociate global objects declared WithEvents >> >> Set objInboxItems = Nothing >> >> End Sub >> >> >> >> Private Sub objInboxItems_ItemAdd(ByVal Item As Object) >> >> Dim olItems As Items, _ >> >> olItem As Object, _ >> >> olMailItem As MailItem, _ >> >> olAttachmentItem As Attachment, _ >> >> bolTimeMatch As Boolean >> >> Set olItems = objInboxItems.Restrict("[Unread] = True") >> >> For Each olItem In olItems >> >> If olItem.Class = olMail Then >> >> Set olMailItem = olItem >> >> 'Change the times on the next line to those you want to use >> >> bolTimeMatch = (Time >= #4:00:00 PM#) And (Time <= #8:30:00 AM#) >> >> If bolTimeMatch Then >> >> Dim objMail As Outlook.MailItem >> >> Set objItem = olMailItem >> >> Set objMail = objItem.Forward >> >> 'PUT THE EXTERNAL EMAIL ADDRESS YOU WANT TO USE ON THE NEXT LINE >> >> objMail.To = "(E-Mail Removed)" >> >> objMail.Send >> >> Set objItem = Nothing >> >> Set objMail = Nothing >> >> End If >> >> End If >> >> Next >> >> End Sub >> >> >> >> Function IsNothing(Obj) >> >> If TypeName(Obj) = "Nothing" Then >> >> IsNothing = True >> >> Else >> >> IsNothing = False >> >> End If >> >> End Function >> >> 'END CODE >>> On Tuesday, March 08, 2011 4:20 PM Josh Skelton wrote: >>> Below is a VBA script, a macro, that will forward emails received in your Outlook Inbox to an external email address. I needed this to forward work emails from Outlook to my Blackberry phone and it works. >>> >>> >>> >>> To use it: >>> >>> 1. Start Outlook >>> >>> 2. Click Tools->Macro->Visual Basic Editor >>> >>> 3. If not already expanded, expand Microsoft Outlook Objects in the Project pane, then click on "ThisOutlookSession" >>> >>> 4. Copy the script below >>> >>> 5. Paste the script into the right-hand pane of the VB Editor >>> >>> 6. Edit the script making the changes as per the comments I included in the code >>> >>> 7. Click the diskette icon on the toolbar to save the changes >>> >>> 8. Close the VB Editor >>> >>> 9. Click Tools->Macro->Security >>> >>> 10. Set Security Level to Medium >>> >>> 11. Close Outlook >>> >>> 12. Start Outlook >>> >>> 13. A dialog-box will appear telling you the ThisOutlookSession contains macros and asking if you want to enable them. Say yes. >>> >>> 14. Test the macro >>> >>> 15. When the macro runs Outlook will present you with another dialog-box advising that a program is trying to access your mailbox and asking if you want to allow it to. Say yes. >>> >>> 16. If a message is received in the mailbox, and if the time is currently between the times you set, then the message will be forwarded to the designated email address. Otherwise, nothing will happen. >>> >>> 17. Once you've verified that the macro works as expected, then you need to sign the macro to avoid having Outlook security warn you each time the macro runs. >>> >>> >>> >>> 'START CODE >>> >>> Private WithEvents objInboxItems As Items >>> >>> >>> >>> Private Sub Application_Startup() >>> >>> Dim objNS As NameSpace >>> >>> Set objNS = Application.GetNamespace("MAPI") >>> >>> ' instantiate Items collections for folders we want to monitor >>> >>> Set objInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items >>> >>> Set objNS = Nothing >>> >>> End Sub >>> >>> >>> >>> Private Sub Application_Quit() >>> >>> ' disassociate global objects declared WithEvents >>> >>> Set objInboxItems = Nothing >>> >>> End Sub >>> >>> >>> >>> Private Sub objInboxItems_ItemAdd(ByVal Item As Object) >>> >>> Dim olItems As Items, _ >>> >>> olItem As Object, _ >>> >>> olMailItem As MailItem, _ >>> >>> olAttachmentItem As Attachment, _ >>> >>> bolTimeMatch As Boolean >>> >>> Set olItems = objInboxItems.Restrict("[Unread] = True") >>> >>> For Each olItem In olItems >>> >>> If olItem.Class = olMail Then >>> >>> Set olMailItem = olItem >>> >>> 'Change the times on the next line to those you want to use >>> >>> bolTimeMatch = (Time >= #4:00:00 PM#) And (Time <= #8:30:00 AM#) >>> >>> If bolTimeMatch Then >>> >>> Dim objMail As Outlook.MailItem >>> >>> Set objItem = olMailItem >>> >>> Set objMail = objItem.Forward >>> >>> 'PUT THE EXTERNAL EMAIL ADDRESS YOU WANT TO USE ON THE NEXT LINE >>> >>> objMail.To = "(E-Mail Removed)" >>> >>> objMail.Send >>> >>> Set objItem = Nothing >>> >>> Set objMail = Nothing >>> >>> End If >>> >>> End If >>> >>> Next >>> >>> End Sub >>> >>> >>> >>> Function IsNothing(Obj) >>> >>> If TypeName(Obj) = "Nothing" Then >>> >>> IsNothing = True >>> >>> Else >>> >>> IsNothing = False >>> >>> End If >>> >>> End Function >>> >>> 'END CODE >>> Submitted via EggHeadCafe >>> ASP.NET JSON Cookies and Excel >>> http://www.eggheadcafe.com/tutorials...and-excel.aspx |
|
||
|
||||
|
Goobus
Guest
Posts: n/a
|
Do you even bother to check the dates of the posts you are replying to?
Typical HoopleHead EggHead. On 3/8/2011 3:21 PM, Josh Skelton wrote: > Below is a VBA script, a macro, that will forward emails received in your Outlook Inbox to an external email address. I needed this to forward work emails from Outlook to my Blackberry phone and it works. > > To use it: > 1. Start Outlook > 2. Click Tools->Macro->Visual Basic Editor > 3. If not already expanded, expand Microsoft Outlook Objects in the Project pane, then click on "ThisOutlookSession" > 4. Copy the script below > 5. Paste the script into the right-hand pane of the VB Editor > 6. Edit the script making the changes as per the comments I included in the code > 7. Click the diskette icon on the toolbar to save the changes > 8. Close the VB Editor > 9. Click Tools->Macro->Security > 10. Set Security Level to Medium > 11. Close Outlook > 12. Start Outlook > 13. A dialog-box will appear telling you the ThisOutlookSession contains macros and asking if you want to enable them. Say yes. > 14. Test the macro > 15. When the macro runs Outlook will present you with another dialog-box advising that a program is trying to access your mailbox and asking if you want to allow it to. Say yes. > 16. If a message is received in the mailbox, and if the time is currently between the times you set, then the message will be forwarded to the designated email address. Otherwise, nothing will happen. > 17. Once you've verified that the macro works as expected, then you need to sign the macro to avoid having Outlook security warn you each time the macro runs. > > 'START CODE > Private WithEvents objInboxItems As Items > > Private Sub Application_Startup() > Dim objNS As NameSpace > Set objNS = Application.GetNamespace("MAPI") > ' instantiate Items collections for folders we want to monitor > Set objInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items > Set objNS = Nothing > End Sub > > Private Sub Application_Quit() > ' disassociate global objects declared WithEvents > Set objInboxItems = Nothing > End Sub > > Private Sub objInboxItems_ItemAdd(ByVal Item As Object) > Dim olItems As Items, _ > olItem As Object, _ > olMailItem As MailItem, _ > olAttachmentItem As Attachment, _ > bolTimeMatch As Boolean > Set olItems = objInboxItems.Restrict("[Unread] = True") > For Each olItem In olItems > If olItem.Class = olMail Then > Set olMailItem = olItem > 'Change the times on the next line to those you want to use > bolTimeMatch = (Time>= #4:00:00 PM#) And (Time<= #8:30:00 AM#) > If bolTimeMatch Then > Dim objMail As Outlook.MailItem > Set objItem = olMailItem > Set objMail = objItem.Forward > 'PUT THE EXTERNAL EMAIL ADDRESS YOU WANT TO USE ON THE NEXT LINE > objMail.To = "(E-Mail Removed)" > objMail.Send > Set objItem = Nothing > Set objMail = Nothing > End If > End If > Next > End Sub > > Function IsNothing(Obj) > If TypeName(Obj) = "Nothing" Then > IsNothing = True > Else > IsNothing = False > End If > End Function > 'END CODE > >> On Monday, January 18, 2010 1:06 PM J_Nettles wrote: > >> Afternoon All: >> >> I am not sure if this can be done or not... we want to auto forward by rule >> email messages during a specific time period... most specifically after >> hours... is it possible to create a rule that would forward emails with a >> specific criteria during a specific set of hours? >> >> Thanks >> -- >> J_Nettles > > >>> On Tuesday, March 08, 2011 4:19 PM Josh Skelton wrote: > >>> Below is a VBA script, a macro, that will forward emails received in your Outlook Inbox to an external email address. I needed this to forward work emails from Outlook to my Blackberry phone and it works. >>> >>> >>> >>> To use it: >>> >>> 1. Start Outlook >>> >>> 2. Click Tools->Macro->Visual Basic Editor >>> >>> 3. If not already expanded, expand Microsoft Outlook Objects in the Project pane, then click on "ThisOutlookSession" >>> >>> 4. Copy the script below >>> >>> 5. Paste the script into the right-hand pane of the VB Editor >>> >>> 6. Edit the script making the changes as per the comments I included in the code >>> >>> 7. Click the diskette icon on the toolbar to save the changes >>> >>> 8. Close the VB Editor >>> >>> 9. Click Tools->Macro->Security >>> >>> 10. Set Security Level to Medium >>> >>> 11. Close Outlook >>> >>> 12. Start Outlook >>> >>> 13. A dialog-box will appear telling you the ThisOutlookSession contains macros and asking if you want to enable them. Say yes. >>> >>> 14. Test the macro >>> >>> 15. When the macro runs Outlook will present you with another dialog-box advising that a program is trying to access your mailbox and asking if you want to allow it to. Say yes. >>> >>> 16. If a message is received in the mailbox, and if the time is currently between the times you set, then the message will be forwarded to the designated email address. Otherwise, nothing will happen. >>> >>> 17. Once you've verified that the macro works as expected, then you need to sign the macro to avoid having Outlook security warn you each time the macro runs. >>> >>> >>> >>> 'START CODE >>> >>> Private WithEvents objInboxItems As Items >>> >>> >>> >>> Private Sub Application_Startup() >>> >>> Dim objNS As NameSpace >>> >>> Set objNS = Application.GetNamespace("MAPI") >>> >>> ' instantiate Items collections for folders we want to monitor >>> >>> Set objInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items >>> >>> Set objNS = Nothing >>> >>> End Sub >>> >>> >>> >>> Private Sub Application_Quit() >>> >>> ' disassociate global objects declared WithEvents >>> >>> Set objInboxItems = Nothing >>> >>> End Sub >>> >>> >>> >>> Private Sub objInboxItems_ItemAdd(ByVal Item As Object) >>> >>> Dim olItems As Items, _ >>> >>> olItem As Object, _ >>> >>> olMailItem As MailItem, _ >>> >>> olAttachmentItem As Attachment, _ >>> >>> bolTimeMatch As Boolean >>> >>> Set olItems = objInboxItems.Restrict("[Unread] = True") >>> >>> For Each olItem In olItems >>> >>> If olItem.Class = olMail Then >>> >>> Set olMailItem = olItem >>> >>> 'Change the times on the next line to those you want to use >>> >>> bolTimeMatch = (Time>= #4:00:00 PM#) And (Time<= #8:30:00 AM#) >>> >>> If bolTimeMatch Then >>> >>> Dim objMail As Outlook.MailItem >>> >>> Set objItem = olMailItem >>> >>> Set objMail = objItem.Forward >>> >>> 'PUT THE EXTERNAL EMAIL ADDRESS YOU WANT TO USE ON THE NEXT LINE >>> >>> objMail.To = "(E-Mail Removed)" >>> >>> objMail.Send >>> >>> Set objItem = Nothing >>> >>> Set objMail = Nothing >>> >>> End If >>> >>> End If >>> >>> Next >>> >>> End Sub >>> >>> >>> >>> Function IsNothing(Obj) >>> >>> If TypeName(Obj) = "Nothing" Then >>> >>> IsNothing = True >>> >>> Else >>> >>> IsNothing = False >>> >>> End If >>> >>> End Function >>> >>> 'END CODE > > >>>> On Tuesday, March 08, 2011 4:20 PM Josh Skelton wrote: > >>>> Below is a VBA script, a macro, that will forward emails received in your Outlook Inbox to an external email address. I needed this to forward work emails from Outlook to my Blackberry phone and it works. >>>> >>>> >>>> >>>> To use it: >>>> >>>> 1. Start Outlook >>>> >>>> 2. Click Tools->Macro->Visual Basic Editor >>>> >>>> 3. If not already expanded, expand Microsoft Outlook Objects in the Project pane, then click on "ThisOutlookSession" >>>> >>>> 4. Copy the script below >>>> >>>> 5. Paste the script into the right-hand pane of the VB Editor >>>> >>>> 6. Edit the script making the changes as per the comments I included in the code >>>> >>>> 7. Click the diskette icon on the toolbar to save the changes >>>> >>>> 8. Close the VB Editor >>>> >>>> 9. Click Tools->Macro->Security >>>> >>>> 10. Set Security Level to Medium >>>> >>>> 11. Close Outlook >>>> >>>> 12. Start Outlook >>>> >>>> 13. A dialog-box will appear telling you the ThisOutlookSession contains macros and asking if you want to enable them. Say yes. >>>> >>>> 14. Test the macro >>>> >>>> 15. When the macro runs Outlook will present you with another dialog-box advising that a program is trying to access your mailbox and asking if you want to allow it to. Say yes. >>>> >>>> 16. If a message is received in the mailbox, and if the time is currently between the times you set, then the message will be forwarded to the designated email address. Otherwise, nothing will happen. >>>> >>>> 17. Once you've verified that the macro works as expected, then you need to sign the macro to avoid having Outlook security warn you each time the macro runs. >>>> >>>> >>>> >>>> 'START CODE >>>> >>>> Private WithEvents objInboxItems As Items >>>> >>>> >>>> >>>> Private Sub Application_Startup() >>>> >>>> Dim objNS As NameSpace >>>> >>>> Set objNS = Application.GetNamespace("MAPI") >>>> >>>> ' instantiate Items collections for folders we want to monitor >>>> >>>> Set objInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items >>>> >>>> Set objNS = Nothing >>>> >>>> End Sub >>>> >>>> >>>> >>>> Private Sub Application_Quit() >>>> >>>> ' disassociate global objects declared WithEvents >>>> >>>> Set objInboxItems = Nothing >>>> >>>> End Sub >>>> >>>> >>>> >>>> Private Sub objInboxItems_ItemAdd(ByVal Item As Object) >>>> >>>> Dim olItems As Items, _ >>>> >>>> olItem As Object, _ >>>> >>>> olMailItem As MailItem, _ >>>> >>>> olAttachmentItem As Attachment, _ >>>> >>>> bolTimeMatch As Boolean >>>> >>>> Set olItems = objInboxItems.Restrict("[Unread] = True") >>>> >>>> For Each olItem In olItems >>>> >>>> If olItem.Class = olMail Then >>>> >>>> Set olMailItem = olItem >>>> >>>> 'Change the times on the next line to those you want to use >>>> >>>> bolTimeMatch = (Time>= #4:00:00 PM#) And (Time<= #8:30:00 AM#) >>>> >>>> If bolTimeMatch Then >>>> >>>> Dim objMail As Outlook.MailItem >>>> >>>> Set objItem = olMailItem >>>> >>>> Set objMail = objItem.Forward >>>> >>>> 'PUT THE EXTERNAL EMAIL ADDRESS YOU WANT TO USE ON THE NEXT LINE >>>> >>>> objMail.To = "(E-Mail Removed)" >>>> >>>> objMail.Send >>>> >>>> Set objItem = Nothing >>>> >>>> Set objMail = Nothing >>>> >>>> End If >>>> >>>> End If >>>> >>>> Next >>>> >>>> End Sub >>>> >>>> >>>> >>>> Function IsNothing(Obj) >>>> >>>> If TypeName(Obj) = "Nothing" Then >>>> >>>> IsNothing = True >>>> >>>> Else >>>> >>>> IsNothing = False >>>> >>>> End If >>>> >>>> End Function >>>> >>>> 'END CODE > > >>>> Submitted via EggHeadCafe >>>> ASP.NET JSON Cookies and Excel >>>> http://www.eggheadcafe.com/tutorials...and-excel.aspx |
|
||
|
||||
|
|
|
| |
![]() |
| Thread Tools | |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| auto forward of sent box emails | at10 | Windows Vista Mail | 1 | 18th Sep 2009 07:03 AM |
| How do I auto-forward specific incoming emails to another email? | MAPSRUS_071207 | Microsoft Outlook Discussion | 6 | 28th May 2009 07:23 PM |
| Dont receive any emails at different periods of time | PM1967 | Microsoft Outlook Discussion | 0 | 27th Nov 2008 10:28 PM |
| How to run a rule only during specific time periods? | Alan | Microsoft Outlook | 2 | 26th Sep 2006 07:26 PM |
| auto forward specific emails | =?Utf-8?B?QW50aG9ueQ==?= | Microsoft Outlook Discussion | 1 | 15th Dec 2004 04:08 PM |
Powered by vBulletin®. Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2010, Crawlability, Inc. |




