Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using Microsoft Outlook 2010. I want to create these two rules.

  1. Specific subjects should go to the specific folder(I know how to do this)
  2. Whenever I forward those emails only in that folder I want to add an email signature to those emails when I forward them.

I cannot still find how to do the second rule. Any help?

Thanks

share|improve this question

1 Answer 1

I suggest rules are not likely to be in the solution.

Try this out. Create a folder called Signatures. The code below assumes it is directly under the Inbox.

From Field Chooser create a User Defined field named Sig in the Signatures folder.

When an item is added to the Signatures folder the User Defined field is set to Yes. This is checked when an item is forwarded from any folder.

Note you have to open the mail, not forward directly from the explorer view

In the ThisOutlookSession module

' http://superuser.com/questions/327614/outlook-macro-to-interrupt-a-reply-all

Private WithEvents insp As Outlook.Inspectors
Private WithEvents MyMailItem As Outlook.MailItem

Private WithEvents olSignatureItems As items

Private Sub insp_NewInspector(ByVal Inspector As Inspector)
If Inspector.currentItem.Size > 0 And Inspector.currentItem.Class = olMail Then

    Debug.Print " A NEW inspector has opened."
    Set MyMailItem = Inspector.currentItem

End If
End Sub

Private Sub MyMailItem_Forward(ByVal Response As Object, cancel As Boolean)
Dim msg As String
Dim Result As Integer

Dim newFwd As MailItem

If MyMailItem Is Nothing Then
    MsgBox "Problem." & vbCr & vbCr & "Try again while" & _
     "-- You are viewing a single message." & vbCr & _
     vbInformation
    Exit Sub

End If

On Error GoTo exitRoutine

If MyMailItem.UserProperties("Sig").Value = "Yes" Then

    Set newFwd = MyMailItem.Forward

    cancel = True

    MyMailItem.Close olDiscard

    newFwd.Body = "This is the signature." & newFwd.Body

    ' or

    ' http://www.rondebruin.nl/mail/folder3/signature.htm

    newFwd.Display

End If

exitRoutine:

End Sub


Private Sub Application_Startup()

Dim objNS As NameSpace
Dim OutApp As Outlook.Application
Dim i As Long

Set OutApp = Outlook.Application
Set objNS = Application.GetNamespace("MAPI")
Set olSignatureItems = objNS.GetDefaultFolder(olFolderInbox).Folders("Signatures").items
' Debug.Print "Adding items to the - Signatures - folder will trigger olSignatureItems_ItemAdd"    

Set objNS = Nothing

End Sub


Private Sub olSignatureItems_ItemAdd(ByVal Item As Object)
' When an item is added to the Signatures folder the User Defined field is set to Yes.

Dim myNameSpace As NameSpace

Set myNameSpace = Application.GetNamespace("MAPI")

Item.UserProperties.Add("Sig", olText).Value = "Yes"
Item.Save

Set myNameSpace = Nothing

End Sub
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.