none
Outlook 2010 - VBScript Item.Forward not Forwarding - Custom Form

    Question

  • HI,

    I have a custom form initially developed in Outlook 2007. Since moving to 2010 I have noticed that the Item.Forward Event Code no longer forwards the item.

    Function Item_Open()
    	msgbox("Form Opened")
    End Function
    
    Function SendButton_Click()
      	Item.Forward()
      	msgbox("Thank you for testing this system.")
    End Function
      
    Function Item_Forward(ByVal ForwardItem)
    	'Set up the fields for the response
      	ForwardItem.To = "me@my_email.com"
      	ForwardItem.Subject = "[2010] TEST EMAIL"
    	msgbox("Should Have Forwarded.")
    End Function
    

    All msg boxes appear when they should.

    Any thoughts?

    Thanks

    Friday, December 03, 2010 11:32 AM

Answers


  • I've spotted it now. In Outlook 2007 I set the standard Forward action to "Send the form immediately" . However in 2010 this option (although still checked from the original form) is disabled.

    The same form works in 2007 but not in 2010 with the same definition and code due to this option no longer being enabled.

    • Marked as answer by EarthwormPath Wednesday, December 08, 2010 9:04 AM
    Wednesday, December 08, 2010 9:03 AM

All replies

  • Hi!

    I'm sure this is probably not the response you were expecting, but this code should not really be sending any message. And in fact, I tested this code with a form in both 2007 and 2010 and there is no message sent.

    This is because the Item.Forward method only creates a new item after executing the forward action. It does not actually send the message by itself. To do that, you would need to add a ForwardItem.Send to the code above.

    So I think the key question is why this form appears to be working for you on Outlook 2007. Overall, I suspect there's some difference in the code that you are using between the two versions.

     

    Monday, December 06, 2010 9:32 PM
    Moderator
  • I agree, i have a feeling i'm barking up the wrong tree here. There is a bit more to the real code but I stripped it all out as I don't think it's relevent.

    I have just got over the pesky bug in Outlook 2010 where it nibbles away at your code every time you deploy a form and guess I may have missed something in the process.

    I have amended the 2010 code to

    Function SendButton_Click()
     	Set fwd = Item.Forward()
        fwd.Send()
     	msgbox("Thank you for testing this system.")
    End Function
    

    And all is well.

    The 2007 code remains the same (without a .Send) and works so I will assume I have done something unexpected and wonderful to make it happen either that or its a nasty hack.

    Thanks

    Tuesday, December 07, 2010 10:21 AM

  • I've spotted it now. In Outlook 2007 I set the standard Forward action to "Send the form immediately" . However in 2010 this option (although still checked from the original form) is disabled.

    The same form works in 2007 but not in 2010 with the same definition and code due to this option no longer being enabled.

    • Marked as answer by EarthwormPath Wednesday, December 08, 2010 9:04 AM
    Wednesday, December 08, 2010 9:03 AM
  • Yes, that would explain it. We intentionally disabled that option in Outlook 2010, so custom forms that depend on that feature in previous versions would need to have their code updated to re-enable this type of functionality.

    I'm sorry this change affected your custom form!

     


    Bill Jacob - Microsoft Customer Service & Support - Messaging Developer
    Friday, December 10, 2010 5:23 PM
    Moderator
  • Hello guys,

    Sorry to dig up an old subject but what's the code which do exactly the same result as when the user press the button "Forward"? The code below works very well but, from my understanding, it create a new form in background which is not accessible for the user.

    Any thoughts?

    Wednesday, January 25, 2012 2:43 PM
  • MailItem.Forward does not display a message, it returns a new MailItem object.

    If oyu need to display it, call MailItem.Display 


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    Wednesday, January 25, 2012 5:26 PM
  • It works! Thanks a lot Dmitry!
    Antoine Lafortune
    Thursday, January 26, 2012 9:03 PM