I have a "recognition database". Every time one person recognize another person. The person chooses other person's name in the drop down and when that record is saved an email should be sent to the person to let him know that recognition for him has been submitted in the database. I am using the code below it works fine and it send email but gives me a security warnings every time an automatic email is sent. It will be pain if everyone has to select "Allow" everytime. So I do not want to have that popup. Please check my code and suggest how I can avoid that security popup.
Private Sub Label140_Click()On Error Resume Next
Dim Combo97 As String
Dim stText96 As String
If IsNull(Me![Combo97]) Then
MsgBox "You must read the Recognition.", vbOKOnly, "More Data Required!"
Exit Sub
End If
RunCommand acCmdSaveRecord
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.Refresh
Me.Dirty = False
Dim oApp As Outlook.Application
Dim oMail As MailItem
Set oApp = CreateObject("Outlook.application")
Set oMail = oApp.CreateItem(olMailItem)
stText96 = Format(Me.Text96, "00000")
oMail.HTMLBody = "A Recognition has been submitted for you in the Recognition database. Please address this Recognition.." & Chr$(13) & _
Chr$(13) & "Recognition Number: " & stText96 & Chr$(13) & "" & Chr$(13) & _
Chr$(13) & "Below is the link to the database... " & Chr$(13) & _
Chr$(13) & "<a href=""" & "C:\Recognition - Front End.mde" & """>" & "C:\Recognition- Front End.mde" & "</a > " & Chr$(13) & _
Chr$(13) & "***THIS IS A SYSTEM GENERATED EMAIL. PLEASE DO NOT REPLY TO THIS EMAIL****."
oMail.Subject = "You have received a new Recognition."
oMail.To = Forms![New Recognition]!Combo97
oMail.CC = ""
oMail.Send
Set oMail = Nothing
Set oApp = Nothing
DoCmd.GoToRecord , , acNewRec
'DoCmd.Close acForm, NewRecognition, acSaveYes
'Exit_addNewRecord_Click:
' Exit Sub
'Err_addNewRecord_Click:
' MsgBox Err.Description
' Resume Exit_addNewRecord_Click
End Sub
The popup I receive is as follows.Capture.PNG
Quote:
Private Sub Label140_Click()On Error Resume Next
Dim Combo97 As String
Dim stText96 As String
If IsNull(Me![Combo97]) Then
MsgBox "You must read the Recognition.", vbOKOnly, "More Data Required!"
Exit Sub
End If
RunCommand acCmdSaveRecord
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.Refresh
Me.Dirty = False
Dim oApp As Outlook.Application
Dim oMail As MailItem
Set oApp = CreateObject("Outlook.application")
Set oMail = oApp.CreateItem(olMailItem)
stText96 = Format(Me.Text96, "00000")
oMail.HTMLBody = "A Recognition has been submitted for you in the Recognition database. Please address this Recognition.." & Chr$(13) & _
Chr$(13) & "Recognition Number: " & stText96 & Chr$(13) & "" & Chr$(13) & _
Chr$(13) & "Below is the link to the database... " & Chr$(13) & _
Chr$(13) & "<a href=""" & "C:\Recognition - Front End.mde" & """>" & "C:\Recognition- Front End.mde" & "</a > " & Chr$(13) & _
Chr$(13) & "***THIS IS A SYSTEM GENERATED EMAIL. PLEASE DO NOT REPLY TO THIS EMAIL****."
oMail.Subject = "You have received a new Recognition."
oMail.To = Forms![New Recognition]!Combo97
oMail.CC = ""
oMail.Send
Set oMail = Nothing
Set oApp = Nothing
DoCmd.GoToRecord , , acNewRec
'DoCmd.Close acForm, NewRecognition, acSaveYes
'Exit_addNewRecord_Click:
' Exit Sub
'Err_addNewRecord_Click:
' MsgBox Err.Description
' Resume Exit_addNewRecord_Click
End Sub