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?
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
Not tested:
mailItem.Subject = "Dept - " & mailItem.Subject
mailItem.Save
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!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.