patkeaveney
Registered User.
- Local time
- Today, 20:39
- Joined
- Oct 12, 2005
- Messages
- 75
Hi
I have searched the forums, and tried to emulate the code samples found but to no avail
Can someome please advise on why my code is not working.
The message box "about to Call Send Email" appears, but then nothing else happens.
I do not get the Msgbox " In Email".
The code below is part of the Add New Student on click event
If SaveAgreedFlag = True Then 'User has replied Yes in Before Update Prodedure
Private Sub SendConfirmationEMail()
On Error GoTo Err_SendEMail
MsgBox "in email"
Dim mess_subject As String
Dim mess_body As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
SendEMailOK = False
If IsNull(Me.EmailAddress) Then
mess_subject = "Confirmation of PAS Training"
mess_body = "Dear " & txtStudentName & vbCrLf & vbCrLf _
& "This is to Confirm your Place on: " & vbCrLf _
& "Course Name " & Forms![frmCourseShedulesStudents].cmbCourses.Text & vbCrLf _
& "Course Schedule " & Forms![frmCourseShedulesStudents].cmbSchedules.Text & vbCrLf _
& "Location " & Forms![frmCourseShedulesStudents].Location.Text
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
End With
SendEMailOK = True
Exit_SendEMail:
Exit Sub
Err_SendEMail:
MsgBox " Error" & Err.Description & Err.Number
Resume Exit_SendEMail:
End Sub
I have searched the forums, and tried to emulate the code samples found but to no avail
Can someome please advise on why my code is not working.
The message box "about to Call Send Email" appears, but then nothing else happens.
I do not get the Msgbox " In Email".
The code below is part of the Add New Student on click event
If SaveAgreedFlag = True Then 'User has replied Yes in Before Update Prodedure
Forms![frmCourseShedulesStudents]![Classes Subform]![txtSaveBox].Value = "Yes"
DoCmd.RunCommand acCmdSaveRecord
MsgBox txtStudentName & vbCrLf & vbCrLf & "Has been Addded to this Course", vbInformation
ElseDoCmd.RunCommand acCmdSaveRecord
MsgBox txtStudentName & vbCrLf & vbCrLf & "Has been Addded to this Course", vbInformation
If MsgBox("Do you want to Add Student " & vbCrLf & vbCrLf _
& txtStudentName & vbCrLf & vbCrLf _
& "to this Course?", vbYesNo + vbQuestion) = vbYes Then
& txtStudentName & vbCrLf & vbCrLf _
& "to this Course?", vbYesNo + vbQuestion) = vbYes Then
Forms![frmCourseShedulesStudents]![Classes Subform]![txtSaveBox].Value = "Yes"
DoCmd.RunCommand acCmdSaveRecord
MsgBox txtStudentName & vbCrLf & vbCrLf & "Has been Addded to this Course", vbInformation
DoCmd.RunCommand acCmdSaveRecord
MsgBox txtStudentName & vbCrLf & vbCrLf & "Has been Addded to this Course", vbInformation
If MsgBox("Do you want to Send a Confirmation Email to" & vbCrLf & vbCrLf _
& txtStudentName & vbCrLf & vbCrLf _
& " ", vbYesNo + vbQuestion) = vbYes Then
& txtStudentName & vbCrLf & vbCrLf _
& " ", vbYesNo + vbQuestion) = vbYes Then
MsgBox "about to Call Send Email"
Call SendConfirmationEMail
End IfCall SendConfirmationEMail
Else
DoCmd.RunCommand acCmdUndo
Forms![frmCourseShedulesStudents]![Classes Subform]![txtSaveBox].Value = "No"
MsgBox txtStudentName & vbCrLf & vbCrLf & "Has NOT been Addded to this Course", vbInformation
Forms![frmCourseShedulesStudents]![Classes Subform]![txtSaveBox].Value = "No"
MsgBox txtStudentName & vbCrLf & vbCrLf & "Has NOT been Addded to this Course", vbInformation
End If
End IfPrivate Sub SendConfirmationEMail()
On Error GoTo Err_SendEMail
MsgBox "in email"
Dim mess_subject As String
Dim mess_body As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
SendEMailOK = False
If IsNull(Me.EmailAddress) Then
MsgBox "No Email Address Entered for " & vbCrLf & vbCrLf _
& txtStudentName, vbExclamation
SendEMailOK = False
Exit Sub
End If& txtStudentName, vbExclamation
SendEMailOK = False
Exit Sub
mess_subject = "Confirmation of PAS Training"
mess_body = "Dear " & txtStudentName & vbCrLf & vbCrLf _
& "This is to Confirm your Place on: " & vbCrLf _
& "Course Name " & Forms![frmCourseShedulesStudents].cmbCourses.Text & vbCrLf _
& "Course Schedule " & Forms![frmCourseShedulesStudents].cmbSchedules.Text & vbCrLf _
& "Location " & Forms![frmCourseShedulesStudents].Location.Text
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.To = Me.EmailAddress
.CC = "patrick.keaveney@hobtpct.nhs.uk"
.Subject = mess_subject
.Body = mess_body
.Send
.CC = "patrick.keaveney@hobtpct.nhs.uk"
.Subject = mess_subject
.Body = mess_body
.Send
End With
SendEMailOK = True
Exit_SendEMail:
Exit Sub
Err_SendEMail:
MsgBox " Error" & Err.Description & Err.Number
Resume Exit_SendEMail:
End Sub
Last edited: