Private Sub cmdsendemailforMobileNo_Click()
''Send Text Messages to the selected PSC Division Employees - Staff Emergency Notification
' --------
Dim oLook As Object
Dim oMail As Object
Dim olns As Outlook.NameSpace
Dim strTO As String
Dim strMessageBody As String
Dim strSubject As String
Dim myDB As DAO.Database
Dim rst As DAO.Recordset
'Do you even have E-Mail Addressess in the Mailing List Table?
If DCount("[txtUserID]", "frmEmpNoMobile") = 0 Then Exit Sub
[COLOR="Red"]Exit Sub[/COLOR]
Set myDB = CurrentDb
Set rst = myDB.OpenRecordset("frmEmpNoMobile", dbOpenSnapshot, dbOpenForwardOnly)
Set oLook = CreateObject("Outlook.Application")
Set olns = oLook.GetNamespace("MAPI")
Set oMail = oLook.CreateItem(0)
' Build the Recipient List
With rst
Do While Not .EOF
strTO = strTO & ![txtUserID] & ";"
.MoveNext
Loop
End With
'Remove Trailing ';'
strTO = Left$(strTO, Len(strTO) - 1)
'******************************* USER DEFINED SECTION ********************************
strMessageBody = "Hi,<br/><br/>" & _
"All PSC work units are required to maintain preparedness for unexpected occurrences as per the Emergency Management (Emergency Relief Centres under the CBD Safety Plan) and Business Continuity Management plans. <br/><br/>" & _
"Communication plans include employee messaging via mobile telephone, by SMS messaging or telephone call. <br/><br/>" & _
"You are receiving this message because we do not have your mobile contact number on our records. <br/><br/>" & _
"Regards <br/>"
strSubject = "Please provide us with your emergency contact number (Mobile Number) [DLM=Sensitive:Personal]"
oMail.Display
'*************************************************************************************
'On Error Resume Next
MsgBox "ERC Message Sent Successfully!", vbOKOnly, "Mail Sent"
Set oMail = Nothing
Set oLook = Nothing
rst.Close
Set rst = Nothing
End Sub