A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Auto populate subject field in outlook



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 10th 12, 12:03 PM
Tallon Tallon is offline
Junior Member
 
First recorded activity at Outlookbanter: May 2012
Posts: 1
Default Auto populate subject field in outlook

Hey,

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

Cheers

Tal
Ads
  #2  
Old May 31st 12, 06:23 PM
NHelp NHelp is offline
Junior Member
 
First recorded activity at Outlookbanter: May 2012
Posts: 2
Default

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

The problem with the using the New E-Mail button is that this is programmed into Outlook and really no way to change the "funtion" of this. However, but creating a macro and assigning it a button, you can 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 like Project1.CreateEmail) and click "Add"
- Select the name from the "Customize Quick Access Toolbar" box and 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 on it, it should do what you want.

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

Hope this helps!
  #3  
Old May 31st 12, 06:56 PM
NDuarte NDuarte is offline
Junior Member
 
First recorded activity at Outlookbanter: May 2012
Posts: 6
Default

There is a way to do this. There is a great article http://blogs.officezealot.com/legault/pages/20086.aspx that explains in 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 the "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 do anything you need to.

Last edited by NDuarte : May 31st 12 at 10:34 PM. Reason: Added Code Tags
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro: Create New Message and Auto populate To Field geosptial Outlook and VBA 5 August 14th 09 03:04 PM
Populate task field based on value of other field jparker Outlook and VBA 9 March 12th 09 04:50 PM
Help needed to auto populate Subject field -Outlook 2003 custom ms Mr Reorg Outlook - Using Forms 6 August 2nd 08 05:41 PM
Populate Message field based on custom field Kryer Outlook - Using Forms 8 September 7th 07 11:19 PM
Populate Company field from Contact field in custom task form Sue Mosher [MVP-Outlook] Outlook - Using Forms 0 January 20th 06 08:37 PM


All times are GMT +1. The time now is 04:28 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.