Adding Body text and Attachment

  • Thread starter Thread starter pauluk
  • Start date Start date
P

pauluk

Does anyone know how to do the following.

A macro which inserts text into the body of a forwarding e-mail an
also an attachment at the same time.

I would require to add this feature to 25 computers, and i know tha
sometimes macros are not saved in outlook is this the case or not
 
Below is the code you need. However, it is strongly recommended that you
implement this as a COM Add-In - it will greatly simplify deployment.
Everything you need to know about that is here:
http://www.outlookcode.com/d/comaddins.htm.

Option Explicit
Dim WithEvents myOlInspectors As Outlook.Inspectors
Dim WithEvents myMsg As Outlook.MailItem
Dim WithEvents myForwardedMessage As Outlook.MailItem

Private Sub myForwardedMessage_Close(Cancel As Boolean)
Set myForwardedMessage = Nothing
End Sub

Private Sub myForwardedMessage_Write(Cancel As Boolean)
myForwardedMessage.Attachments.Add "C:\Temp\myFile.txt", olByValue
myForwardedMessage.Body = "Add this text to the body." &
myForwardedMessage.Body
End Sub

Private Sub myMsg_Close(Cancel As Boolean)
Set myMsg = Nothing
End Sub

Private Sub myMsg_Forward(ByVal Forward As Object, Cancel As Boolean)
Set myForwardedMessage = Forward
End Sub

Private Sub myOlInspectors_NewInspector(ByVal Inspector As Inspector)
If Inspector.CurrentItem.Class <> olMail Then Exit Sub
Set myMsg = Inspector.CurrentItem
End Sub

Private Sub Application_Startup()
Set myOlInspectors = Application.Inspectors
End Sub

Private Sub Application_Quit()
Set myOlInspectors = Nothing
End Sub
 
Back
Top