ajcannon Posted April 1, 2009 Report Share Posted April 1, 2009 Hi,I have taken a VBA script from the Microsoft website. I want to forward all my OL mails to a web account and the normal 'rules and alerts' wont do it - I think our IT guys have disabled it.I had this in debug mode and when it fired - on arrival of a mail - i stepped through and it worked fine. I saved it and exited the VBA editor and recieved another mail but......nothing happened.Any advice/guidance most appreciated - BTW total novice with VBAcheersAlastairCode----------------------------------------------------------------------------------------------------Public WithEvents myOlItems As Outlook.ItemsPublic 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).ItemsEnd SubPrivate Sub myOlItems_ItemAdd(ByVal Item As Object) ' 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 "forward@address" ' Send it myForward.Send End IfEnd Sub Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted April 2, 2009 Report Share Posted April 2, 2009 I have used VBA on Outlook before, but I have no idea why incoming mail does not trigger your script.Perhaps a better place to ask for help is news://msnews.microsoft.com/microsoft.publ...per.outlook.vba - this is also available as a web interface; google for 'microsoft.public.office.developer.outlook.vba'. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.