thread702-396121
I am wanting to send automatic emails from Access 2003 when I cancel a schedule.
I have found the above thread to be very helpful in creation of the code. But, I am having an error and I am afraid that I my be off base with it. I have been working on this a long time and need help.
When I run this I am getting the following error:
Run-time error '438':
Project doesn't support this property or method.
This is my code:
Option Compare Database
Private Sub CommandClose_Click()
Dim strEmail, strBody As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
'**creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
'**************************************************************
'*create string with email address
strEmail = Forms![SchedSearchList]![UserLoginsfrm].textemail
strBody = txtTDate & Chr(13) & Chr(13)
strBody = strBody & "Staff" & "," & Chr(13) & Chr(13)
strBody = strBody & "The following schedule has been cancelled:" & Chr(13) & Chr(13) & Chr(13)
strBody = strBody & "Client: " & " " & Forms!SchedSearchList![SchedClientTable Qry subform].FullName & Chr(13)
strBody = strBody & "Date: " & Forms!SchedSearchList!ScheduleClientfrm.TextDate & Chr(13)
strBody = strBody & "Time: " & " " & SchedSearchList!ScheduleClientfrm.TextStart & " " & SchedSearchList!ScheduleClientfrm.TextEnd & Chr(13)
strBody = strBody & "Worker: " & Forms!SchedSearchList!ScheduleClientfrm.Workername & Chr(13) & Chr(13)
strBody = strBody & "Reason: " & CancelReasonfrm.CancelReas & Chr(13)
strBody = strBody & "Notes: " & [CancelNotes Querysfrm].Notes & Chr(13) & Chr(13)
strBody = strBody & "Thank you," & Chr(13) & Chr(13)
strBody = strBody & "CareEase"
'***creates and sends email
With objEmail
.To = strEmail
.Subject = "Schedule Cancellation"
.Body = strBody
.Send
End With
Set objEmail = Nothing
'****closes Outlook. remove if you do not want to close Outlook
objOutlook.Quit
Exit Sub
DoCmd.Close acForm, CancelReasonfrm, acSaveYes
DoCmd.Close acForm, [CancelNotes Queryfrm], acSaveYes
End Sub
Debug is highlighting this line:
strEmail = Forms![SchedSearchList]![UserLoginsfrm].textemail
Can anyone help put me on track? Thanks
I am wanting to send automatic emails from Access 2003 when I cancel a schedule.
I have found the above thread to be very helpful in creation of the code. But, I am having an error and I am afraid that I my be off base with it. I have been working on this a long time and need help.
When I run this I am getting the following error:
Run-time error '438':
Project doesn't support this property or method.
This is my code:
Option Compare Database
Private Sub CommandClose_Click()
Dim strEmail, strBody As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
'**creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
'**************************************************************
'*create string with email address
strEmail = Forms![SchedSearchList]![UserLoginsfrm].textemail
strBody = txtTDate & Chr(13) & Chr(13)
strBody = strBody & "Staff" & "," & Chr(13) & Chr(13)
strBody = strBody & "The following schedule has been cancelled:" & Chr(13) & Chr(13) & Chr(13)
strBody = strBody & "Client: " & " " & Forms!SchedSearchList![SchedClientTable Qry subform].FullName & Chr(13)
strBody = strBody & "Date: " & Forms!SchedSearchList!ScheduleClientfrm.TextDate & Chr(13)
strBody = strBody & "Time: " & " " & SchedSearchList!ScheduleClientfrm.TextStart & " " & SchedSearchList!ScheduleClientfrm.TextEnd & Chr(13)
strBody = strBody & "Worker: " & Forms!SchedSearchList!ScheduleClientfrm.Workername & Chr(13) & Chr(13)
strBody = strBody & "Reason: " & CancelReasonfrm.CancelReas & Chr(13)
strBody = strBody & "Notes: " & [CancelNotes Querysfrm].Notes & Chr(13) & Chr(13)
strBody = strBody & "Thank you," & Chr(13) & Chr(13)
strBody = strBody & "CareEase"
'***creates and sends email
With objEmail
.To = strEmail
.Subject = "Schedule Cancellation"
.Body = strBody
.Send
End With
Set objEmail = Nothing
'****closes Outlook. remove if you do not want to close Outlook
objOutlook.Quit
Exit Sub
DoCmd.Close acForm, CancelReasonfrm, acSaveYes
DoCmd.Close acForm, [CancelNotes Queryfrm], acSaveYes
End Sub
Debug is highlighting this line:
strEmail = Forms![SchedSearchList]![UserLoginsfrm].textemail
Can anyone help put me on track? Thanks