Add
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Hide
Tag = 0
Cancel = True
End If
lbl_Exit:
Exit Sub
End Sub
to the userform code and change the main macro to include the extra tag option
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim strSubject As String, strText As String
Dim oFrm As New UserForm1 'the name of the userform
If TypeName(Item) = "MailItem" Then
With oFrm
.Show
Select Case .Tag
Case Is = 0: Cancel = True: GoTo lbl_Exit 'the X has been clicked
Case Is = 1: strText = "A:"
Case Is = 2: strText = "B:"
Case Else: strText = "C:"
End Select
End With
Unload oFrm
strSubject = Item.Subject
If Not Left(strSubject, 2) = strText Then
strSubject = strText & strSubject
Item.Subject = strSubject
End If
End If
lbl_Exit:
Set oFrm = Nothing
Exit Sub
End Sub