Option Explicit
Private Const FORWARD_TO_EMAIL As String = "me@email.com"
Sub AutoForwardEmail(outlookMailItem As Outlook.mailItem)
On Error GoTo ErrorSub
Dim orgMail As Outlook.mailItem
Dim newMail As Outlook.mailItem
Set orgMail = Application.Session.GetItemFromID(outlookMailItem.EntryID)
Set newMail = orgMail.Forward
newMail.Recipients.Add FORWARD_TO_EMAIL
newMail.DeleteAfterSubmit = True
newMail.Body = orgMail.Body
newMail.BodyFormat = olFormatPlain
newMail.Send
EndSub:
Set newMail = Nothing
Set orgMail = Nothing
Exit Sub
ErrorSub:
MsgBox "Unexpected Error: " & Err.Description
Resume EndSub:
End Sub
No comments:
Post a Comment