Can I use a macro within Outlook ?

  • Thread starter Thread starter Roger
  • Start date Start date
R

Roger

I am using Outlook 2003. I have written vba for macros in other office apps
but not Outlook. We get a lot of emails with sales details. Many are
forwarded to another email address outside the company once they have been
checked. Because they have to be checked and decision made re forwarding or
not, I cannot use the autoforward as part of a rule.

I want a simple macro to forward a message I highlight in the inbox to a
nominated email address, using the message's subject line as the subject
line in the forwarding email (ie using the default subject). Is this
possible from within Outlook ?

thanks

Roger
 
Yes, Outlook has a VBA environment, accessed just like that in other
applications with Alt+F11 or Tools | Macros | VBA. These pages can help you
get started:

http://www.outlookcode.com/article.aspx?id=49
http://www.outlookcode.com/article.aspx?ID=40

The item selected in the current window is returned by
Application.ActiveExplorer.Selection(1), so your macro would be something
like this:

Sub MyMacro()
Dim msg As Outlook.MailItem
Set itm = Application.ActiveExplorer.Selection(1)
Set msg = itm.Forward
msg.To = "(e-mail address removed)"
msg.Send
Set msg = Nothing
Set itm = Nothing
End Sub
 
Great, thanks

Roger

Sue Mosher said:
Yes, Outlook has a VBA environment, accessed just like that in other
applications with Alt+F11 or Tools | Macros | VBA. These pages can help
you get started:

http://www.outlookcode.com/article.aspx?id=49
http://www.outlookcode.com/article.aspx?ID=40

The item selected in the current window is returned by
Application.ActiveExplorer.Selection(1), so your macro would be something
like this:

Sub MyMacro()
Dim msg As Outlook.MailItem
Set itm = Application.ActiveExplorer.Selection(1)
Set msg = itm.Forward
msg.To = "(e-mail address removed)"
msg.Send
Set msg = Nothing
Set itm = Nothing
End Sub
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
Back
Top