1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
'Option Explicit
'Clean subject of mails incoming
'https://www.developpez.net/forums/d2157789/logiciels/microsoft-office/outlook/vba-outlook/vba-nettoyage-objets-mails/
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim l_o_item As Object
Dim l_o_mailItem As Outlook.mailItem
Set l_o_item = Application.Session.GetItemFromID(EntryIDCollection)
If TypeOf l_o_item Is mailItem Then
Set l_o_mailItem = l_o_item
With l_o_mailItem
.Subject = Replace(.Subject, "[EXT] ", "")
.Subject = Replace(.Subject, "AW: ", "")
.Subject = Replace(.Subject, "FW: ", "")
.Subject = Replace(.Subject, "FWD: ", "")
.Subject = Replace(.Subject, "RE: ", "")
.Subject = Replace(.Subject, "SV: ", "")
.Subject = Replace(.Subject, "TR: ", "")
'
.Subject = Replace(.Subject, "[EXT]", "")
.Subject = Replace(.Subject, "AW:", "")
.Subject = Replace(.Subject, "FW:", "")
.Subject = Replace(.Subject, "FWD:", "")
.Subject = Replace(.Subject, "RE:", "")
.Subject = Replace(.Subject, "SV:", "")
.Subject = Replace(.Subject, "TR:", "")
'
.Subject = Replace(.Subject, "[EXT] ", "")
.Subject = Replace(.Subject, "AW ", "")
.Subject = Replace(.Subject, "FW ", "")
.Subject = Replace(.Subject, "FWD ", "")
'.Subject = Replace(.Subject, "RE ", "")
.Subject = Replace(.Subject, "SV ", "")
.Subject = Replace(.Subject, "TR ", "")
'
.Subject = Replace(.Subject, "[Ext] ", "")
.Subject = Replace(.Subject, "Aw: ", "")
.Subject = Replace(.Subject, "Fw: ", "")
.Subject = Replace(.Subject, "Fwd: ", "")
.Subject = Replace(.Subject, "Re: ", "")
.Subject = Replace(.Subject, "Sv: ", "")
.Subject = Replace(.Subject, "Tr: ", "")
'
.Subject = Replace(.Subject, "[Ext]", "")
.Subject = Replace(.Subject, "Aw:", "")
.Subject = Replace(.Subject, "Fw:", "")
.Subject = Replace(.Subject, "Fwd:", "")
.Subject = Replace(.Subject, "Re:", "")
.Subject = Replace(.Subject, "Sv:", "")
.Subject = Replace(.Subject, "Tr:", "")
'
.Subject = Replace(.Subject, "[Ext] ", "")
.Subject = Replace(.Subject, "Aw ", "")
.Subject = Replace(.Subject, "Fw ", "")
.Subject = Replace(.Subject, "Fwd ", "")
'.Subject = Replace(.Subject, "Re ", "")
.Subject = Replace(.Subject, "Sv ", "")
.Subject = Replace(.Subject, "Tr ", "")
'
.Save
End With
End If
Set l_o_item = Nothing
Set l_o_mailItem = Nothing
End Sub
'Clean subject of mails outgoing
'From https://fr.extendoffice.com/documents/outlook/5120-outlook-remove-subject-prefixes.html
Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
'
RemovePrefixOut Item, "AW"
RemovePrefixOut Item, "FW"
RemovePrefixOut Item, "FWD"
RemovePrefixOut Item, "RE"
RemovePrefixOut Item, "SW"
RemovePrefixOut Item, "TR"
'
End Sub
Function RemovePrefixOut(Item As Object, Str As String)
'
Dim xSubject As String
'
If InStr(Item.Subject, Str) > 0 Then
xSubject = Replace(Item.Subject, Str & ":", "", vbTextCompare)
Item.Subject = Trim(xSubject)
Item.Save
End If
'
End Function |
Partager