Hi Stuar
The error you're encountering ("Run-time error '429': ActiveX component can't create object") typically occurs when there is an issue with the registration or availability of the required ActiveX component, in this case, the Outlook application.
Since your Access database is running within a remote environment where opening Outlook directly is restricted, you can try an alternative approach to send emails without relying on the Outlook application itself. One option is to use the System.Net.Mail namespace in VBA to send emails via an SMTP server.
Here's an example of VBA code that uses System.Net.Mail to send an email:
Sub SendEmail()
Dim objMessage As Object
' Create the email object
Set objMessage = CreateObject("System.Net.Mail.MailMessage")
' Set the sender and recipient
objMessage.From = "sender@example.com"
objMessage.To = "recipient@example.com"
' Set the subject and body
objMessage.Subject = "Test Email"
objMessage.Body = "This is a test email."
' Set the SMTP server details
Dim objSMTP As Object
Set objSMTP = CreateObject("System.Net.Mail.SmtpClient")
objSMTP.Host = "smtp.example.com"
objSMTP.Port = 587
objSMTP.EnableSsl = True
objSMTP.Credentials = CreateObject("System.Net.NetworkCredential", "username", "password")
' Send the email
objSMTP.Send(objMessage)
' Clean up objects
Set objMessage = Nothing
Set objSMTP = Nothing
End Sub
Make sure to replace the placeholders (sender@example.com, recipient@example.com, smtp.example.com, username, and password) with the appropriate values for your email setup.
By using this code, you can send emails from your Access database without relying on the Outlook application. It utilizes the SMTP server and the System.Net.Mail namespace to handle the email sending process.