Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Add-Ins / January 2004

Tip: Looking for answers? Try searching our database.

Macro to forward email

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rOB - 28 Jan 2004 14:31 GMT
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!
Ken Slovak - [MVP - Outlook] - 28 Jan 2004 16:01 GMT
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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginners Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> I'd like to create a macro button in Outlook to do the
> following:
[quoted text clipped - 7 lines]
>
> Thanks!
Rob - 28 Jan 2004 16:51 GMT
Awesome! It works.  Thanks!

>-----Original Message-----
>Outlook has no macro recorder, all macros in Outlook are coded using
[quoted text clipped - 56 lines]
>
>.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.