I am a newbie when it comes to VB ans I'm trying to send emails from Access 2016 but I recieve and "array Index" error which I do not understand ans cannot apply it to my code......can anyone throw some light on it? Code below
' Send the email using rst! from strSQL
oMail.Body = "Hi, " & rst![FirstName] & " " & rst![Surname] & ", Please find attached your Subscription Reminder for the current year!"
oMail.Subject = "Subscription Invoice"
oMail.To = rst!Email
oMail.Attachments.Add CurrentProject.Path & "" & stDocName & ".pdf"
oMail.SendUsingAccount = oApp.Session.Accounts.Item(2)
oMail.Send
Set oMail = Nothing
Set oApp = Nothing
Set rst = Nothing
'+++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++
DoCmd.Close acReport, stDocName, acSaveNo
Msgbox "The Subscription Invoice for " & rst![FirstName] & " " & rst![Surname] & " has been sent."
Exit_CmdSubInvoice_Click:
Exit Sub
Err_CmdSubInvoice_Click:
Msgbox Err.Description
Resume Exit_CmdSubInvoice_Click
End Sub