Lef_pl
01-14-2022, 04:21 AM
Hello,
Could You please advise:
I wrote a Outlook macro that checks message title for key phrases and when they are not included:
1. Stops sending message,
2. Opens menu with suggested actions => add specific phrase
After (2) user can send email once again.
My problem is:
I would like to have it on one click
When I change "Cancel = True" to "Cancel = False" it works for sending or replying to emails...but it crashes entire application when email is forwarded.
Could You please advice on any workaround?
Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim question As String
Dim strSubj As String
If TypeName(Item) = "MailItem" Then
strSubj = Item.subject
Item.Display
If InStr(Item.subject, "SOMETHING1") > 0 Or InStr(Item.subject, "SOMETHING2") > 0 Or InStr(Item.subject, "SOMETHING3") > 0 Then
Exit Sub
Else
question = MsgBox("PLEASE DO SOMETHING", , "CAUTION")
MENU.Top = (Application.ActiveWindow.Top + Application.ActiveWindow.Height / 4) - (MENU.Height / 4)
MENU.Left = (Application.ActiveWindow.Left + Application.ActiveWindow.Width / 20) - (MENU.Width / 20)
With MENU 'show menu that helps to do something ;)
.SHOW
End With
Cancel = True
strSubj = Item.subject
strSubj = DWType & strSubj
Item.subject = strSubj
End If
End If
Item.Display
DWtype = ""
end sub
Could You please advise:
I wrote a Outlook macro that checks message title for key phrases and when they are not included:
1. Stops sending message,
2. Opens menu with suggested actions => add specific phrase
After (2) user can send email once again.
My problem is:
I would like to have it on one click
When I change "Cancel = True" to "Cancel = False" it works for sending or replying to emails...but it crashes entire application when email is forwarded.
Could You please advice on any workaround?
Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim question As String
Dim strSubj As String
If TypeName(Item) = "MailItem" Then
strSubj = Item.subject
Item.Display
If InStr(Item.subject, "SOMETHING1") > 0 Or InStr(Item.subject, "SOMETHING2") > 0 Or InStr(Item.subject, "SOMETHING3") > 0 Then
Exit Sub
Else
question = MsgBox("PLEASE DO SOMETHING", , "CAUTION")
MENU.Top = (Application.ActiveWindow.Top + Application.ActiveWindow.Height / 4) - (MENU.Height / 4)
MENU.Left = (Application.ActiveWindow.Left + Application.ActiveWindow.Width / 20) - (MENU.Width / 20)
With MENU 'show menu that helps to do something ;)
.SHOW
End With
Cancel = True
strSubj = Item.subject
strSubj = DWType & strSubj
Item.subject = strSubj
End If
End If
Item.Display
DWtype = ""
end sub