Operating system:: Windows 10
Outlook version: Outlook 365
Email type or host: Exchange Online
Outlook version: Outlook 365
Email type or host: Exchange Online
Hello, Diane,
following code works great for replacement of prefixes AW:/WG: to Re:/Fwd: in any subject lines of my outgoing emails. Unfortunatelly, in case of new messages/messages without above mentioned prefixes, subject line will be completely removed and emails are sending with blank subject line.
Could you please check this code and get him to work properly? I tried to comment the line Item.Subject = Trim(strSubject). With this change subject line of new messages remains but AW:/WG: will not be replaced by Re:/Fwd:.
Your help will be highly appreciated.
Thank you in advance.
following code works great for replacement of prefixes AW:/WG: to Re:/Fwd: in any subject lines of my outgoing emails. Unfortunatelly, in case of new messages/messages without above mentioned prefixes, subject line will be completely removed and emails are sending with blank subject line.
Could you please check this code and get him to work properly? I tried to comment the line Item.Subject = Trim(strSubject). With this change subject line of new messages remains but AW:/WG: will not be replaced by Re:/Fwd:.
Your help will be highly appreciated.
Thank you in advance.
Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
'https://windowsreport.com/outlook-subject-prefix-fw-re/
Dim strSubject As String
If InStr(Item.Subject, "AW") > 0 Then
'If you don't want the prompt,
'You can remove the MsgBox line and its correspoding "Else … End If" lines.
If MsgBox("Do you want to remove the prefix 'AW'?", vbYesNo) = vbYes Then
strSubject = Replace(Item.Subject, "AW:", "Re:", vbTextCompare)
Else
strSubject = Item.Subject
End If
End If
If InStr(Item.Subject, "WG") > 0 Then
If MsgBox("Do you want to remove the prefix 'WG'?", vbYesNo) = vbYes Then
strSubject = Replace(Item.Subject, "WG:", "Fwd:", vbTextCompare)
Else
strSubject = Item.Subject
End If
End If
Item.Subject = Trim(strSubject)
Item.Save
End Sub