Outlook 2013 Auto name checking upon Tab or Click off To field(s)

Brian Lain

New Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server
We have some users with itchy clicker fingers who love to hit Send without completing To addresses. I’ve enabled “Automatic name checking” in Group Policy, but all that does it put a squiggly red line beneath the still incomplete address (if it’s non-unique). I realize they get prompted to Check Names when they hit Send, but apparently those itchy clicker fingers love to double click random names (gotta love those PEBCAK errors).

My question is, is there a way to invoke a “Check Names” prompt auto/programmatically when tabbing from, or clicking off, the To/Cc fields (prior to hitting Send)?
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
It's easier to auto check when the Send button is hit, then cancel if a name cannot be resolved. Just keep in mind that even nonsense is resolved as long as it looks like a valid email address.
Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
  if item.recipients.resolveall=false then
    cancel=true
  endif
End Sub
 

Brian Lain

New Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server
It's easier to auto check when the Send button is hit, then cancel if a name cannot be resolved. Just keep in mind that even nonsense is resolved as long as it looks like a valid email address.
Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
  if item.recipients.resolveall=false then
    cancel=true
  endif
End Sub
Where would I implement this code snippet? (Sorry, not a macro/VBA guy.)
[DOUBLEPOST=1440688654][/DOUBLEPOST]
Names autoresolve against contacts (and properly formatted addresses resolve) when you tab out of the fields but the dialog only comes up if they don't take the steps to fix unresolved entries before sending.
Right. I'm just looking for a way to force a Check Names prior to hitting Send.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Michael - what about triggering a macro as they tab out of the fields - maybe a dialog box that says there are unresolvable addresses that need fixed?
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
There's no event that triggers when you tab out. You could use the PropertyChange event, which is quite complicated to use for addresses. Thus I mentioned the ItemSend event. It should sufficiently do the trick: do not send if there's an unresolved address.
 

Brian Lain

New Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server
There's no event that triggers when you tab out. You could use the PropertyChange event, which is quite complicated to use for addresses. Thus I mentioned the ItemSend event. It should sufficiently do the trick: do not send if there's an unresolved address.
Just to clarify, how does the Send process get modified in this instance? User hits Send, Check Names pops up as usual due to an unresolved address, user selects address from list....then what? Are they returned to the composition window until they hit Send again?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Hmmm. Resolve is triggered before item send - so the macro doesn't really add any benefit as outlook won't attempt to send bad addresses until they are resolved. You want to jump in before the resolve dialog comes up or cancels resolve and throws it back to the message.
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Sure, Outlook wouldn' send anyway. The problem actually is: If users don't look at what they click on, there's nothign you can do to prevent it.

There's the BeforeCheckNames event, I just don't see how it could be helpful in this case.
 

Brian Lain

New Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server
What about the trigger that causes the red underlines? Is there a way to hook into that? Or would that also hook into spell check as well?
 

Brian Lain

New Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server
Taking a different approach, what about changing the button layout for new messages? As a test, I've customized the ribbon to display Send and Check Names buttons on the far left (right above the actual Send button). And I've figured out how to "design this form" via the Developer menu, but I see no option to remove the Send button from the form (or to add a Check Names button right next to it). If we could do that, then the new layout plus a little user re-training could go a long way toward resolving the issue. Thoughts?
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
What about the trigger that causes the red underlines?
The only event is the BeforeCheckNames event. Depending on the outcome, Outlook will underline the address in red or in black. There's no event to tell you that CheckNames has finished and is going to prompt the user.

What do you really want to achieve? If you don't get the users now to select the names they really want to send to, how would a CheckNames button change that? BTW pressing alt+k would also call the CheckNames function.

As the user could also pick a wrong name in the first place, you could always ask before sending 'Are you sure recipient x is the one you want?'. These users will treat that prompt as they always do, they'll click OK without checking if it's really ok. So you'll end up moving in a circle.
 

Brian Lain

New Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server
Thanks for your help Michael and Diane. We've decided to scrap the custom form/programmatic solution for now. We're going with a 3 pronged approach: 1-Enable Auto-resolve, 2-Enable Delayed Send, and 3-User policy.

So on the delayed send piece (2), I know how to create a rule to do that with all outgoing email (thanks to one of Diane's previous forum posts). And I can export that rule to an RWZ file, and manually import it. The question now is if there is a way to either import the RWZ file via script, or just create the new rule via script?
 

Brian Lain

New Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server
Just wanted to chime in one last time to thank you both again for your patience and assistance on this, and to update you on what we finally implemented for the delayed send piece.

So we ended up creating a macro (with help from one of Diane's how-to's) to modify the Send process itself (see code below). If the subject line contains the word "immediate" then Send proceeds as usual, if not it defers delivery for 5 minutes from now. That gives users enough time to grab it in their Outbox and make any needed corrections or changes

The odd thing about deploying this is that it appears as if the code needs to be viewed (Alt+F11) to be activated. Does that make sense to you? Any way around that?

Code:
Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
  Dim objMailItem As MailItem       ' to hold mail item
  Dim intErrNumber As Integer
  '
  On Error GoTo Err_Handler         'Error Handling
  Set objMailItem = Item            'Set object to mail item just sent
  'If objMailItem.Subject <> "Immediate" Then
  If InStr(1, objMailItem.Subject, "Immediate", vbTextCompare) = 0 Then
    objMailItem.DeferredDeliveryTime = DateAdd("n", 5, Now)     'Delay is + 2 minutes
   End If
  Exit Sub
Err_Handler:
'Due to lack of concentration of the code writing genius there has been a bit of an error,
'  lets tell someone about it by popping up a message box with a detailed description on the screen.
  intErrNumber = Err.Number
  If intErrNumber = 13 Then
   'Nothing.
  Else
    MsgBox ("An error has occured on line " & Erl & ", with a description: " & Err.Description & ", and an error number " & _
       Err.Number)
  End If
End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Correct, if you deploy code, users will need to open the editor to enable it. There is no way around it, should of compiling an addin instead of using a macro.
 

Brian Lain

New Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server
Correct, if you deploy code, users will need to open the editor to enable it. There is no way around it, should of compiling an addin instead of using a macro.
What would be the easiest way to compile it into an add-in? Visual Studio? Would that add-in then be deploy-able (MSI, EXE, etc.)?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Visual studio and yes, you can deploy it automatically.
 

Brian Lain

New Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server
Sorry to resurrect what seemed like a closed case, but we're receiving some push back from users (careful what they wish for) regarding the new send delay. I'm wondering if there's a way to set the DeferDelivery time to say 5 seconds if the user checks a box in a custom message form. Then rework the script to not overwrite any non-default delay (so the above override, plus say a compose Sat/send Mon type scenario as well). The scripting logic seems like the easy part, whereas tying it to a user selection seems much more involved. Any thoughts?
 

dohodoho

New Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server 2010
Hi Brian,

As an alternative to a delay, you could look into using various add-ins for preventing accidental emails being sent. "Safeguard Send" and "SafeSend" are a few that do this in various forms, they might help you.
 
Top