Macro to forward email

R

rOB

I'd like to create a macro button in Outlook to do the
following:

Forward the highlighted message to a particular address
and add specific text to the top of the message.

Is this possible? Can someone point me in the right
diretion? For some reason I can't record macro's in
Outlook.

Thanks!
 
K

Ken Slovak - [MVP - Outlook]

Outlook has no macro recorder, all macros in Outlook are coded using
VBA code.

For information on creating a button and assigning a macro to it see
http://www.slipstick.com/outlook/toolbar.htm#macro

Open Outlook VBA by clicking Alt+F11. Insert a code module using
Insert, Module. In that code module place a Sub. In that Sub use code
something like this:

Sub ForwardItem()
Dim oExplorer As Outlook.Explorer
Dim oMail As Outlook.MailItem
Dim oOldMail As Outlook.MailItem

Set oExplorer = Application.ActiveExplorer
If oExplorer.Selection.Item(1).Class = olMail Then
Set oOldMail = oExplorer.Selection.Item(1)
Set oMail = oOldMail.Forward
oMail.Recipients.Add "address you want it sent to"
oMail.Recipients.Item(1).Resolve
If oMail.Recipients.Item(1).Resolved Then
oMail.Body = "my added text" & vbCRLF & oMail.Body
oMail.Send
Else
MsgBox "Could not resolve " &
oMail.Recipients.Item(1).Name
End If
Else
MsgBox "Not a mail item"
End If

Be aware that secure versions of Outlook will fire the security
prompts on accessing the Recipients collection and on Send telling you
that a program is accessing your address book and that a program is
trying to send email. Avoiding those prompts is a matter of advance
programming.
 
R

Rob

Awesome! It works. Thanks!

-----Original Message-----
Outlook has no macro recorder, all macros in Outlook are coded using
VBA code.

For information on creating a button and assigning a macro to it see
http://www.slipstick.com/outlook/toolbar.htm#macro

Open Outlook VBA by clicking Alt+F11. Insert a code module using
Insert, Module. In that code module place a Sub. In that Sub use code
something like this:

Sub ForwardItem()
Dim oExplorer As Outlook.Explorer
Dim oMail As Outlook.MailItem
Dim oOldMail As Outlook.MailItem

Set oExplorer = Application.ActiveExplorer
If oExplorer.Selection.Item(1).Class = olMail Then
Set oOldMail = oExplorer.Selection.Item(1)
Set oMail = oOldMail.Forward
oMail.Recipients.Add "address you want it sent to"
oMail.Recipients.Item(1).Resolve
If oMail.Recipients.Item(1).Resolved Then
oMail.Body = "my added text" & vbCRLF & oMail.Body
oMail.Send
Else
MsgBox "Could not resolve " &
oMail.Recipients.Item(1).Name
End If
Else
MsgBox "Not a mail item"
End If

Be aware that secure versions of Outlook will fire the security
prompts on accessing the Recipients collection and on Send telling you
that a program is accessing your address book and that a program is
trying to send email. Avoiding those prompts is a matter of advance
programming.







.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top