Opening Outlook remote desktop

Stuart 0 Reputation points
2023-05-12T07:19:47.6666667+00:00

Hi All
We are currently in the process of moving our Access database to a RD Web Access - RemoteApp and Desktop Connection, it all works as it should apart from using VBA to open Outlook (outside of the remote connection) and create an Email. anyone have any ideas how we can do this?

Unfortunately the security levels do not allow outlook to be opened within the remote access so trying to force it open outside of this remote window,
I currently get a run-time error of '429', ActiveX Component cant create object.



Windows for business | Windows Client for IT Pros | User experience | Remote desktop services and terminal services
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Khaled Elsayed Mohamed 1,335 Reputation points
    2023-06-12T10:14:29.6866667+00:00

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.