RE: Run VBA Code from 'new mail message' on standard toolbar
- From: Carmi <Carmi@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 28 Mar 2006 21:41:01 -0800
Dear Eric - firstly thank you for your help and pointing me to your blog. It
was very helpful as it is written in a way that makes it very easy to
understand (especially the parts about the This OutlookSession and the Class
Module). In all honesty I dont think I fully understand the code related to
Inspector Object all that well but the code works!... well nearly.
I do have a follow on question relating to a discussion between yourself and
Nick on the same blog (1/18/2005 9:06am) concerning the different olMail
events. The (very simple) question is;
What is the event to trap for the creation of a new mail message?
I understand, and can find, the appropriate references for using a
objMailItem_Forward or objMailItem_Reply events but for the life of me cant
find one for creating a new message.
Any direction would be greatly appreciated
Carmi
"Eric Legault [MVP - Outlook]" wrote:
Instead of trapping clicks on the Send button, it would be better to trap.
additions to the Inspectors collection. See my blog post here:
Getting a Handle on Your E-mails with VBA:
http://blogs.officezealot.com/legault/articles/2224.aspx
New e-mails can be created by shortcut keys and other methods, so relying on
a button click won't catch all of the situations.
Try resolving during Item_Send, and cancelling the event if an address is
invalid.
--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/
"Carmi" wrote:
Outlook 2003
I have found and edited the following code (sourced from Sue Mosher) and
assigned it to a button on a customised tool bar but would prefer to have
this run when I click on the 'new mail message' button on the standard tool
bar. Is this possible?
Sub CreateNewMail()
'Creates a new e-mail item
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Dim strEmail As String
'Set Application
Set olApp = Outlook.Application
'Set new email item
Set objMail = olApp.CreateItem(olMailItem)
'Ask user to record project number
strEmail = InputBox("Please enter Job Number or Client Name", _
"Job Number")
'Set Job Number in BC
objMail.CC = strEmail
'Display the email
objMail.Display
'Resolve project number to find project address
objMail.Recipients.ResolveAll
End Sub
Also the way I am using the 'resolve' does not seem to work. The project
address is not resolved until I hot the send button. This is no big issue
but I if someone could help I would prefer to check the project number and
find the correct address before I hit the send button.
Thanks
Carmi
- Follow-Ups:
- Prev by Date: Re: Paste cells from Excel into message body
- Next by Date: RE: Run VBA Code from 'new mail message' on standard toolbar
- Previous by thread: VBA or VBScript
- Next by thread: RE: Run VBA Code from 'new mail message' on standard toolbar
- Index(es):
Loading