Outlook email security issue

I'm using the following code to send an email via a command button on a form.  But the sender gets a security warning (see attached file).  Is there a way to avoid this?  Maybe different code?

Here's the current onclick code:

Private Sub Command116_Click()

   Dim olApp As Object
   Dim objMail As Object
   Dim RegHrs, OThrs, totHrs
    RegHrs = Format([txtTotRegHrs], "#.00")
    OThrs = Format([txtTotOThrs], "#.00")
    totHrs = Format([txtTotTimeCardHrs], "#.00")

   On Error Resume Next 'Keep going if there is an error
   Set olApp = GetObject(, "Outlook.Application") 'See if Outlook is open

    If Err Then 'Outlook is not open
       Set olApp = CreateObject("Outlook.Application") 'Create a new instance
    End If
  'Create e-mail item
   Set objMail = olApp.CreateItem(olMailItem)

   With objMail
   'Set body format to HTML
     .BodyFormat = olFormatHTML
     .To = Me.txtApproverEmail
     .Subject = "Time Card Approval Notification For Employee - " & [txtEmployeeName] & " - Dated " & [txtTranxDateHeader]
     .HTMLBody = "<htmltags>Regular Hours = " & RegHrs & "<br>Overtime Hours = " & OThrs & "<br>Total Hours = " & totHrs & "<br></htmltags>"
   End With

   Me.chkbxSubmittedToApprover = True

  MsgBox "Request for approval has been sent.  Be sure to close the form."

 End Sub
Who is Participating?
AccessGuy1763Connect With a Mentor Commented:
I'm not saying this list is comprehensive, but from my experience here's a couple of ways to deal with this:

#1 - This message does not show up if Outlook detects a valid Antivirus installation.  You can  check this by going to Tools > Trust Center > Programmatic Access.  On the very bottom, it should say Antivirus Status: Valid or Invalid.  If it says invalid, Outlook will prompt.  If it says Valid, it will not.  I know this is true at least for Outlook 2007.

#2 - This is not my favorite resolution as it makes the computer more vulnerable, but you can install 3rd party apps which basically click the message automatically.  I think one I've used before is called "ClickYes", but there's a number available you could check out, I'm sure.
Jeffrey CoachmanMIS LiasonCommented:
...Or use one of the many Access email systems that bypass Outlook directly,
for example:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.