Automatic Subject

M

Melanie

Every time I create a new email I would like a default subject to appear. How
do I get it to automate for all new emails?

Also if forwards and replies do not contain the default subject, on sending
can i write a macro to add it to the beginning of the subject field?

Ta muchly
 
M

Michael Bauer

Hi Melanie,

for the default subject I would customize the Outlook Formular itself
(open the Inspector and click on Extras/Formulars/Design this Formular
[or something like that]).

For handling replies you could use my sample. It handles MailItems only.
For the forwards you can easily copy the mechanism. The FaceID (number
in Application_Startup for retrieving a CommandBarButton) is 356.


Option Explicit
Private WithEvents ReplyButton As Office.CommandBarButton

Private Sub Application_Startup()
Set ReplyButton = Application.ActiveExplorer.CommandBars.FindControl(,
354)
End Sub

Private Sub ReplyButton_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean)
CancelDefault = ReplyCurrentMailAndAddSubject
End Sub

Private Function ReplyCurrentMailAndAddSubject() As Boolean
Dim obj As Object
Dim oMail As Outlook.MailItem
Dim oReply As Outlook.MailItem
Const FIX_SUBJECT As String = "Reply from Melanie: "

Select Case True
Case TypeOf Application.ActiveWindow Is Outlook.Inspector
Set obj = Application.ActiveInspector.CurrentItem
Case Else
With Application.ActiveExplorer.Selection
If .Count Then
Set obj = .Item(1)
End If
End With
End Select

If TypeOf obj Is Outlook.MailItem Then
Set oMail = obj
Set oReply = oMail.Reply

If InStr(1, oReply.Subject, FIX_SUBJECT, vbTextCompare) = 0 Then
oReply.Subject = FIX_SUBJECT & oReply.Subject
End If

oReply.Display
ReplyCurrentMailAndAddSubject = True
End If
End Function
 
M

Melanie

Michael, thank you for your comprehensive assistance, it is appreciated.

Michael Bauer said:
Hi Melanie,

for the default subject I would customize the Outlook Formular itself
(open the Inspector and click on Extras/Formulars/Design this Formular
[or something like that]).

For handling replies you could use my sample. It handles MailItems only.
For the forwards you can easily copy the mechanism. The FaceID (number
in Application_Startup for retrieving a CommandBarButton) is 356.


Option Explicit
Private WithEvents ReplyButton As Office.CommandBarButton

Private Sub Application_Startup()
Set ReplyButton = Application.ActiveExplorer.CommandBars.FindControl(,
354)
End Sub

Private Sub ReplyButton_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean)
CancelDefault = ReplyCurrentMailAndAddSubject
End Sub

Private Function ReplyCurrentMailAndAddSubject() As Boolean
Dim obj As Object
Dim oMail As Outlook.MailItem
Dim oReply As Outlook.MailItem
Const FIX_SUBJECT As String = "Reply from Melanie: "

Select Case True
Case TypeOf Application.ActiveWindow Is Outlook.Inspector
Set obj = Application.ActiveInspector.CurrentItem
Case Else
With Application.ActiveExplorer.Selection
If .Count Then
Set obj = .Item(1)
End If
End With
End Select

If TypeOf obj Is Outlook.MailItem Then
Set oMail = obj
Set oReply = oMail.Reply

If InStr(1, oReply.Subject, FIX_SUBJECT, vbTextCompare) = 0 Then
oReply.Subject = FIX_SUBJECT & oReply.Subject
End If

oReply.Display
ReplyCurrentMailAndAddSubject = True
End If
End Function
--
Viele Grüße
Michael Bauer


Melanie said:
Every time I create a new email I would like a default subject to appear. How
do I get it to automate for all new emails?

Also if forwards and replies do not contain the default subject, on sending
can i write a macro to add it to the beginning of the subject field?

Ta muchly
 

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