Can I use a macro within Outlook ?

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
 
S

Sue Mosher [MVP]

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
 
R

Roger

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
 

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