I am using the code below as discussed previously. I have another problem. My table "Employee" in the recognition database has employee information. It has a field for employee "name". Large number of people have names with middle name. Email works fine for people with just first and last name. Code is not able search the middle name as it does not exist in our company outlook. Code is doing its work. I don't want to delete the middle names from the database to match outlook. Is it possible to make modification in the code so that code just search for only first and last name not middle name. Below is the
Code:
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
DoCmd.SetWarnings 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.SetWarnings True
'DoCmd.Close acForm, NewRecognition, acSaveYes
'Exit_addNewRecord_Click:
' Exit Sub
'Err_addNewRecord_Click:
' MsgBox Err.Description
' Resume Exit_addNewRecord_Click
End Sub