Consulting

Results 1 to 1 of 1

Thread: Outlook crash on Item_send modification

  1. #1
    VBAX Regular
    Joined
    Jan 2014
    Posts
    7
    Location

    Outlook crash on Item_send modification

    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
    Last edited by Aussiebear; 04-15-2023 at 10:48 AM. Reason: Adjusted the code tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •