Auto populate subject field in outlook

T

Tallon

Hey,

I have an exchange mailbox here and I want to poulate the subject fiel
with some text every time someone clicks 'New Mail'

Is this possible?

If so, how do I do it?

Google results are not very informative

Cheers

Ta
 
M

Michael Bednarek

I have an exchange mailbox here and I want to poulate the subject field
with some text every time someone clicks 'New Mail'

Is this possible?

If so, how do I do it?

Google results are not very informative

Apparently, you have to use the NewInspector event and then inspect
MailItem.Sent to determine whether this is a new message. See
<http://stackoverflow.com/questions/7996292/outlook-event-newmail-newitem.
and
<http://stackoverflow.com/questions/...d-event-when-user-clicks-new-email-in-outlook>.

The subject can be manipulated through the .Subject property.
 
N

NHelp

Once way to do it would be to create a Macro that does this And set i
up as a quick action button to create the e-mail instead of using th
"New E-Mail" button.

The problem with the using the New E-Mail button is that this i
programmed into Outlook and really no way to change the "funtion" o
this. However, but creating a macro and assigning it a button, you ca
accomplish what you are asking.

Macro:

Public Sub CreateEmail()

'Create the oMail object
Dim oMail As Outlook.MailItem

'Create a new mail item
Set oMail = Application.CreateItem(olMailItem)

'Set the subject
With oMail
.Subject = "This is the subject"
.Display
End With

End Sub

Once you put this into a module and save it, do the following:

- File -> Options
- Click Quick Access Toolbar
- In the dropdown box for "Choose commands from:", select "Macros"
- Click on the name of the Macro (Should be something lik
Project1.CreateEmail) and click "Add"
- Select the name from the "Customize Quick Access Toolbar" box an
select modify
- You can rename itand even set an icon
- Click "Ok" until all the windows disappear
- The new Icon should appear in the top left corner. When you click o
it, it should do what you want.

Some other notes:
You can also set the To, CC, BCC, Body, Send From, Reply To, an
attachments as well by using .To, .CC, .BCC, .Body, .SentOnBehalfOfName
.ReplyRecipients.Add, and .Attachments.Add respectively.

Hope this helps
 
N

NDuarte

There is a way to do this. There is a great articl
http://blogs.officezealot.com/legault/pages/20086.aspx that explains i
detail, but here is the general idea:

- Open VBA (Alt-F11) and open "ThisOutlookSession"
- Put in the following code:

Code
-------------------

Option Explicit

Dim myMailItemTrapper As clsMailItemTrapper

Private Sub Application_Startup()

Set myMailItemTrapper = New clsMailItemTrapper

End Sub

Private Sub Application_Quit()

Set myMailItemTrapper = Nothing

End Sub

-------------------


- Click Insert -> Class Module and rename it to clsMailItemTrapper

- In the new class, put in the following:

Code
-------------------

Option Explicit

Dim WithEvents objInspectors As Outlook.Inspectors

Dim WithEvents objOpenInspector As Outlook.Inspector

Dim WithEvents objMailItem As Outlook.MailItem

Private Sub Class_Initialize()

Set objInspectors = Application.Inspectors

End Sub

Private Sub Class_Terminate()

Set objOpenInspector = Nothing

Set objInspectors = Nothing

Set objMailItem = Nothing

End Sub

Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)

If Inspector.CurrentItem.Class = olMail Then

Set objMailItem = Inspector.CurrentItem

Set objOpenInspector = Inspector

End If

End Sub

Private Sub objMailItem_Open(Cancel As Boolean)

objMailItem.Subject = "Put your subject here"

End Sub

-------------------

- Save the VBA code and restart Outlook. Anytime someone pressed th
"New E-Mail" button, the subject will automatically be populated.

As I said, check out that site for more details as you can just about d
anything you need to
 

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