Forward Email with its attachment in Outlook 2010

There is no need to use the Explorer object in the code:

Sub ForwardEmail(item As Outlook.MailItem)
  Dim oMail As MailItem    

  On Error GoTo Release

  If item.Class = olMail Then
     Set oMail = item.Forward
     oMail.Subject = oMail.Subject
     oMail.HTMLBody = "Have a nice day." & vbCrLf & oMail.HTMLBody
     oMail.Recipients.Add "email address here"

     oMail.Save
     oMail.Send
  End If
 Release:
  Set oMail = Nothing
  Set oExplorer = Nothing
End Sub

You may find the Getting Started with VBA in Outlook 2010 article helpful.


There is an unnecessary condition

If oExplorer.Selection.item(1).Class = olMail Then

that may cause the forwarding to be bypassed.

Sub ForwardEmail(item As Outlook.MailItem)
' Dim oExplorer As Outlook.Explorer
Dim oMail As MailItem
' Set oExplorer = Application.ActiveExplorer

On Error GoTo Release

' If oExplorer.Selection.item(1).Class = olMail Then

Set oMail = item.Forward
oMail.Subject = oMail.Subject
oMail.HTMLBody = "Have a nice day." & vbCrLf & oMail.HTMLBody
oMail.Recipients.Add "email address here"

' oMail.Save
oMail.Send

' End If

Release:
Set oMail = Nothing
' Set oExplorer = Nothing
End Sub