Link to home
Start Free TrialLog in
Avatar of Compoint
Compoint

asked on

How to add a custom forward button in outlook 2003?

Hi,

I need an easy way to add a custom button to the message window in outlook 2003 that will forward the e-mail with automatic integrations of voting buttons (approve;reject).
I searched for macro's and vba to do this, but without succes.

Thnx
Avatar of David Lee
David Lee
Flag of United States of America image

Hi, Compoint.

That's pretty simple.  Here's the code for automatically creating a forward with the voting buttons.  Please try it out and if it's okay, then I'll explain how to add the button for firing it.  To use this

1.  Add the code to Outlook
2.  Open a message
3.  Run the macro
Sub ForwardWithVotingButtons()
    Dim olkMsg As Outlook.MailItem
    Set olkMsg = Outlook.Application.ActiveInspector.CurrentItem.Forward()
    With olkMsg
        .VotingOptions = "Approve;Reject"
        .Display
    End With
End Sub

Open in new window

Avatar of Compoint
Compoint

ASKER

I tried it out and it works exactly like I wanted to.   thnx!

So, step 2?
If forgot to mention, when forwarding I also want to add something to the subject (at the beginning), like for example "what do you think of this"
ASKER CERTIFIED SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thnx BlueDevilFan, you really helped me out out here. Works great!!!

The only thing I was wondering about: In the Macros window (alt + f8), I am unable to create a new macro. This one is still under ThisOutlookSession. It's not really a problem as long as their is no need for another macro, which probably won't.
You're welcome.  Glad I could help out.

You can have any number of macros in ThisOutlookSession and/or any other code module.  You can create additional modules by right-clicking on ThisOutlookSession and selecting Insert -> Module fromt he resulting menu.
Is there a way to add the button automatically, with the same icon as for the forward and with "Forward with voting"?
I have to install this button on several pc's so I need an automation for installing the button. I'm trying to customize the code from https://www.experts-exchange.com/questions/21190142/Outlook-VBA-reference-Application-Form.html 
Is it possible to automate the placing of the button like in the jpg attached
untitled.JPG
Yes, that's possible.  I'll post the code for doing that as quick as I can.
This code must go in the ThisOutlookSession module.  Here's a link to a page with the FaceId's
http://www.outlookexchange.com/articles/toddwalker/BuiltInOLKIcons.asp

Const msoButtonIconAndCaption = 3
Public WithEvents myOlInspectors As Outlook.Inspectors
 
Private Sub myOlInspectors_NewInspector(ByVal Inspector As Outlook.Inspector)
    Dim olkBar As Object, olkControl As Object
    If Inspector.CurrentItem.Class = olMail Then
        Set olkBar = Inspector.CommandBars.Item("Standard")
        'Test to see if the toolbar button already exists
        Set olkControl = olkBar.FindControl(, , "ForwardWithVoting")
        'If not found, then create button
        If olkControl Is Nothing Then
            Set olkControl = olkBar.Controls.Add(, , , 7, True)
            With olkControl
                .Caption = "Forward with Voting"
                'Change the FaceId value on the next line'
                .FaceId = 1676
                .Style = msoButtonIconAndCaption
                .Tag = "ForwardWithVoting"
                .Visible = True
            End With
        End If
        Set olkBar = Nothing
   End If
End Sub
 
Private Sub Application_Quit()
    Set myOlInspectors = Nothing
End Sub
 
Private Sub Application_Startup()
    Set myOlInspectors = Application.Inspectors
End Sub

Open in new window

First of all, thank you for your responses.

I added the new code in thisoutlooksession and the old one in module 1. When I run the macro it opens up a forward mail of the mail the was open, with the voting buttons enabled and with the text added to the subject. When I close it and reopen the mail, the button has been placed (I changed the placing from 7 to 4) with the text and an icon, but when I click on it, nothing happens.
I' ve been through the code to look for reference to the code in module 1 but can't find it. I would like to get a bit more insight so I can fix it myself, but since I've never worked with vba It's hard to get grip on it.
Oops.  That's my fault.  Looking back at the code I see I omitted one statement.  Somewhere between lines 13 and 20 add this command

    .OnAction = "ForwardWithVotingButtons"
This is great. Thnx alot BlueDevilFan!!!
You're welcome.  Glad I could help out.
Greetings

What do I need to do If I only want to add the "forward" to all button without the votting option.

Thanks in advance.
Hi, thetrueflesh.

There're already "forward" and "forward to all" buttons on the toolbar.  Why would you want to add another?
Hi BlueDevilFan

Thanks for your answer, perhaps I did not get myself crear, what my boss want it's a custom button that will automatically include all his contacts in his address book without having to add one by one, so he can send a mail to all fo them.
Oh.  Sorry, I didn't get that this was the goal.  Yeah, that's possible.  Rather than deal with this here in this question's discussion, would you mind opening a new question?
Ok I will open a new quetion!

Thanks in advance!
If you want to send me a link once you've opened it, then I'll be able to respond quicker.  You can post the link to the new question here, reference this question when you create the new question, or email me a link to the new question.  My email address is in my profile.