I have code to send out emails. I am trying to add after the body of the email but then I get an error saying the object doesn't support this property or method. How can I add the image to my code?
Code:
Private Sub CmdEmail_Click()
On Error GoTo SendEmail_Err
Dim myOlApp As Object
Dim myNameSpace As Object
Dim myFolder As Object
Dim myItem As Object
Dim myAttachments, myRecipient As Object
Dim recipient As String
Dim file_name As String
Dim mySubject As Object
Dim dbs As Object
Dim rst As Object
Dim strSQL As String
Dim SentOnBehalfOfName As String
If Me.CountEmail > 0 Then
strSQL = "SendStudentEmail" 'Select the Query where you want your information to be drawn from
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strSQL)
rst.MoveFirst
While Not rst.EOF
recipient = recipient & rst!StudentEmail & ";" 'This is the email address that you corresponds to your recipient
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myAttachments = myItem.Attachments
Set myRecipient = myItem.Recipients.Add(recipient)
myItem.SentOnBehalfOfName = "enter email"
'myItem.BCC = "" 'Enter any other email recipient that you want CC'd for this email
'"Message Subject String Here"
myItem.Subject = Me.EmailSubject
'"Put Message Body Text Here"
myItem.Body = IIf(IsNull(rst!FirstName), "Dear Former Student", rst!FirstName) & "," & Chr(13) & Chr(10) & Chr(13) & Chr(10) & Me.EmailBody & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "If you would like to unsubscribe to this email list, please email us at unsubscribe@example.org with UNSUBSCRIBE in the Subject." & Chr(13) & Chr(10) & Me.Image16
myItem.Display
rst.MoveNext
Wend
'DoCmd.Close acForm, "SendEmail" 'Closes the form
'DoCmd.OpenForm "EmailConfirmation" 'Opens Email Confirmation Form
Set myRecipient = Nothing
Set myAttachments = Nothing
Set myItem = Nothing
Set myOlApp = Nothing
Set rst = Nothing
Else
response = MsgBox("There are no recipients to send to.", vbOKOnly)
End If
SendEmail_Exit:
Exit Sub
SendEmail_Err:
MsgBox Err.Description
Resume SendEmail_Exit
End Sub