Button to automate new message settings

  • Thread starter Thread starter Peter Herbison
  • Start date Start date
P

Peter Herbison

Wow. This customizing of Outlook looks difficult. I had what I thought were
modest requirements but suddenly this looks hard.

I want to add 2 buttons to Outlook 2003. Both will invoke the "new message"
dialog but with different settings for the message signature and different
"have replies sent to" in the message options. This would save my users
having to manually remember to set the correct values.

How do I go about doing this? There does not appear to be a traditional
Macro facilty in Outlook.

Do I have to create custom forms and somehow default the correct values?

Where will I find documentation on automating Outlook?

Thanks
 
Actually, Outlook does support Macros, but you can't record them like you do in Word/Excel.

The code to do what you want is actually pretty straightforward. Paste the following macro into your Outlook VBA IDE (access it via ALT+F11); you need to edit the ThisOutlookSession module.

Sub SendCustomEmail()
Dim objItem As Outlook.MailItem

Set objItem = Application.CreateItem(olMailItem)
objItem.Body = vbCrLf & vbCrLf & "--" & vbCrLf & "My custom signature"
objItem.ReplyRecipients.Add "(e-mail address removed)"
objItem.Display
End Sub

Just modify the code for your requirements. You might want to create a SendCustomEmail2 with the variations for the message body and reply recipient.

You can now run these macros by a custom toolbar button/menu item. Right-click on the toolbar, choose "Customize", and click the "Commands" tab. Scroll down the left list, choose "Macros", and drag "Project1.ThisOutlookSession.SendCustomEmail" from the right list to the desired location. Note that "Project1" may be named something else in your case.

For a good introduction to automating Outlook, see "Visual Basic and VBA Coding in Microsoft Outlook" (http://www.outlookcode.com/d/vb.htm).
 
Eric,

Yes, Yes, Yes. Thankyou very much. This is the start I wanted. A simple but
effective bit of code....in fact this does most of what I wanted.

Do you also know how I could choose one of the existing signatures rather
than hard coding it as you have?

Where do I find documentation about this object model? With that I should be
able to work it out myself (well, maybe).

Thanks again.

Peter Herbison

Eric Legault said:
Actually, Outlook does support Macros, but you can't record them like you do in Word/Excel.

The code to do what you want is actually pretty straightforward. Paste
the following macro into your Outlook VBA IDE (access it via ALT+F11); you
need to edit the ThisOutlookSession module.
Sub SendCustomEmail()
Dim objItem As Outlook.MailItem

Set objItem = Application.CreateItem(olMailItem)
objItem.Body = vbCrLf & vbCrLf & "--" & vbCrLf & "My custom signature"
objItem.ReplyRecipients.Add "(e-mail address removed)"
objItem.Display
End Sub

Just modify the code for your requirements. You might want to create a
SendCustomEmail2 with the variations for the message body and reply
recipient.
You can now run these macros by a custom toolbar button/menu item.
Right-click on the toolbar, choose "Customize", and click the "Commands"
tab. Scroll down the left list, choose "Macros", and drag
"Project1.ThisOutlookSession.SendCustomEmail" from the right list to the
desired location. Note that "Project1" may be named something else in your
case.
For a good introduction to automating Outlook, see "Visual Basic and VBA
Coding in Microsoft Outlook" (http://www.outlookcode.com/d/vb.htm).
 
Back
Top