I an wrting a script to execute under a mail rule.
The script generates a message based on a template, appends some information from the incoming email, displays the email to the user and gives them the option to send it

The problem is that I cant get .display to display the message.
  • If I comment out the line with .display (as below) the msgbox pops up and, if the users clicks Yes (unwise as he has not seen the message!) the message appears in the outbox exactly as intended.
  • If I uncomment the .display line I get the msgbox "Before .display" and the script aborts (no other msgbox messages and no error message) and goes on to process the next mail item.


Sub SendNew(Item As Outlook.MailItem)

Dim objMsg As MailItem
MsgBox "In SendNew"
Set objMsg = Application.CreateItemFromTemplate("C:\Users\Rincewind\AppData\Roaming\Microsoft\Templates\Test.oft")
NL = "<br/>"
With objMsg
    .HTMLBody = .HTMLBody & NL & "- - - - - - - - - - - - - - - - - - - - " & NL & "." _
                & NL & "." & "From:  " & Item.SenderEmailAddress & NL & "." & NL & "." _
                & NL & Item.Subject & NL & "." & NL & "." & Item.HTMLBody
    .Subject = "FW: " & Item.Subject
    .Recipients.Add "me AT test.com"        'Send to selected persong
    MsgBox "Before .display"
'   .Display
    MsgBox "After .display"
End With
answer = MsgBox("sendNewNunn. Send Message?", vbQuestion + vbYesNo + vbDefaultButton2)
If answer = vbYes Then objMsg.Send
Set objMsg = Nothing
End Sub
What am I doing wrong?
And why do I not get an error message from VBA when it aborts the script?
TFAI