5

Basically, we have a rule setup to run a script when a code word is detected in the body of an incoming message. The script will append the current subject header with a word in front. For example, Before: "Test Message", After: "Dept - Test Message". Any ideas?

4

3 回答 3

4

Or if you need an entire script:

Do the Run a script with the MailItem as the parameter.

Sub RewriteSubject(MyMail As MailItem)

    Dim mailId As String
    Dim outlookNS As Outlook.NameSpace
    Dim myMailItem As Outlook.MailItem

    mailId = MyMail.EntryID
    Set outlookNS = Application.GetNamespace("MAPI")
    Set myMailItem = outlookNS.GetItemFromID(mailId)

    ' Do any detection here

    With myMailItem 
      .Subject = "Dept - " & mailItem.Subject
      .Save
    End With

    Set myMailItem = Nothing
    Set outlookNS = Nothing

End Sub
于 2008-09-18T19:01:56.717 回答
0

Not tested:

mailItem.Subject = "Dept - " & mailItem.Subject
mailItem.Save 
于 2008-09-18T18:56:49.133 回答
0
Sub AppendSubject(MyMail As MailItem)
    Dim strID As String
    Dim mailNS As Outlook.NameSpace
    Dim mailItem As Outlook.MailItem

    strID = MyMail.EntryID
    Set mailNS = Application.GetNamespace("MAPI")
    Set mailItem = mailNS.GetItemFromID(strID)
    mailItem.Subject = "Dept - " & mailItem.Subject
    mailItem.Save

    Set mailItem = Nothing
    Set mailNS = Nothing
End Sub

Are we missing anything? EDIT: Doh! You already answered our question with a full script... Thanks!

于 2008-09-18T19:09:47.103 回答