Consulting

Results 1 to 4 of 4

Thread: Outlook VB Macro Problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Outlook VB Macro Problem

    Good Morning,

    I have created a VB macro in Outlook 2010 to warn end users before sending to a bad e-mail address (see below). It worked fine when I first created it and modified it a couple of times for other addresses. Now it suddenly will not work for some reason.

    I set this up under Project1 in "ThisOutlookSession" as Application "ItemSend". I have tried the following to get it to work:

    1) Recompiled the macro.
    2) Exited and restarted Outlook.
    3) Created a selfcert digital certificate and changed the security settings in the Trust Center for macros to "Notifications for digitally signed macros, all other macros disabled".
    4) I even tried "Enabled all macros" ... still no luck.
    5) Deleted everything and started again by creating the same macro from scratch ... still not working.

    I am fairly new to VB macros and this is frustrating (since I had it working at first), so could really use some help.

    Thanks in advance!

    =======================================================

    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
         
    On Error Resume Next
     ' use lower case for the address
     ' LCase converts all addresses in the To field to lower case
    If InStr(LCase(Item.To), "bad e-mail address here") Then
          Prompt$ = "You are sending this to " & Item.To & ". Are you sure you want to send it?"
           If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check Address") = vbNo Then
             Cancel = True
           End If
      End If
         
    End Sub
    Last edited by SamT; 08-31-2014 at 05:08 AM. Reason: Added Code Tags with the # Icon

Posting Permissions

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