创建规则以添加签名

创建规则以添加签名

我正在使用 Microsoft Outlook 2010。我想创建这两条规则。

  1. 具体的主题应该放到具体的文件夹中(我知道如何做)
  2. 每当我转发该文件夹中的电子邮件时,我都想在转发这些电子邮件时添加电子邮件签名。

我仍然不知道如何执行第二条规则。有什么帮助吗?

谢谢

答案1

我认为规则不太可能成为解决方案。

尝试一下。创建一个名为 Signatures 的文件夹。下面的代码假设它直接位于收件箱下。

从字段选择器中在签名文件夹中创建一个名为 Sig 的用户定义字段。

当项目添加到签名文件夹时,用户定义字段将设置为是。当项目从任何文件夹转发时,都会检查此项。

请注意,您必须打开邮件,而不是直接从资源管理器视图转发

在 ThisOutlookSession 模块中

' 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

相关内容