poohbear2012
Registered User.
- Local time
- Today, 11:50
- Joined
- Jan 8, 2012
- Messages
- 30
Hi
I have button on one of my forms to enable users to send an email. I have the following code on the On Click command. Nothing happens when I click on the button on the form and no errors pop up.
Private Sub btnsendemail_Click()
If IsNull(Me.txtcount) Then
MsgBox "There are no appointments to email"
Else
On Error GoTo handdler
Dim mailItem As Outlook.mailItem
Dim outlookApp As Outlook.Application
Set outlookApp = New Outlook.Application
Set mailItem = outlookApp.CreateItem(olMailItem)
mailItem.Subject = "Appointment Reminder"
mailItem.To = Me.GPEMailAddressTextBox
mailItem.CC = "joe.bloggs@me.com"
mailItem.Body = "Thank you for your referral regarding" & Nz(Me.Forename, "") & " " & Nz(Me.Surname, "") & vbnewline & "We have booked an outpatient referral appointment for them to be seen in" & vbnewline
mailItem.Body = "We have booked an outpatient referral appointment for them to be seen in" & Nz(Me.Consultant, "") & " clinic on " & Nz(Me.[1st_Appointment], "") & vbnewline & "at insert time." & vbnewline & "_"
mailItem.Body = "Kind Regards" & vbnewline & "_"
mailItem.Body = "The Appointments Team." & vbnewline & "_"
mailItem.Body = "This message has been automatically generated by the Database System"
End If
handdler:
If Err.Number = 2501 Then
MsgBox "You have cancelled the request", vbInformation
Else
Exit Sub
End If
End Sub
Many Thanks
Trisha Thorpe
I have button on one of my forms to enable users to send an email. I have the following code on the On Click command. Nothing happens when I click on the button on the form and no errors pop up.
Private Sub btnsendemail_Click()
If IsNull(Me.txtcount) Then
MsgBox "There are no appointments to email"
Else
On Error GoTo handdler
Dim mailItem As Outlook.mailItem
Dim outlookApp As Outlook.Application
Set outlookApp = New Outlook.Application
Set mailItem = outlookApp.CreateItem(olMailItem)
mailItem.Subject = "Appointment Reminder"
mailItem.To = Me.GPEMailAddressTextBox
mailItem.CC = "joe.bloggs@me.com"
mailItem.Body = "Thank you for your referral regarding" & Nz(Me.Forename, "") & " " & Nz(Me.Surname, "") & vbnewline & "We have booked an outpatient referral appointment for them to be seen in" & vbnewline
mailItem.Body = "We have booked an outpatient referral appointment for them to be seen in" & Nz(Me.Consultant, "") & " clinic on " & Nz(Me.[1st_Appointment], "") & vbnewline & "at insert time." & vbnewline & "_"
mailItem.Body = "Kind Regards" & vbnewline & "_"
mailItem.Body = "The Appointments Team." & vbnewline & "_"
mailItem.Body = "This message has been automatically generated by the Database System"
End If
handdler:
If Err.Number = 2501 Then
MsgBox "You have cancelled the request", vbInformation
Else
Exit Sub
End If
End Sub
Many Thanks
Trisha Thorpe