For those of you who need to use TLS for your mail server instead of SSL, here's some code from ChatGPT which you may find useful. I have not tried this myself, as I've never needed to use anything other than SSL:
I've been using Sendgrid with Microsoft Access for literally a decade, and I have never had to use TLS. I'm just using straight SMTP with an API key and port 465. However, a quick query of GPT gives me this:
In Microsoft Access VBA, when sending an email via SMTP using CDO, you need to set the appropriate configuration fields to enable TLS instead of SSL. TLS is often referred to as "STARTTLS" in SMTP configurations. Below is an example configuration for enabling TLS:
CodeSub SendEmailWithTLS() Dim objMessage As Object Dim objConfig As Object Dim Fields As Object
' Create the email object Set objMessage = CreateObject("CDO.Message") Set objConfig = CreateObject("CDO.Configuration") Set Fields = objConfig.Fields
' Configure the SMTP server settings With Fields .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.example.com" ' Replace with your SMTP server .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587 ' Port for TLS .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 ' cdoSendUsingPort .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 ' Basic Authentication .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "your_username" ' Your email username .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "your_password" ' Your email password .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False ' Disable SSL .Item("http://schemas.microsoft.com/cdo/configuration/smtpusetls") = True ' Enable TLS .Update End With
' Configure the email message With objMessage Set .Configuration = objConfig .To = "[email protected]" ' Replace with recipient email .From = "[email protected]" ' Replace with sender email .Subject = "Test Email with TLS" .TextBody = "This is a test email sent using TLS." .Send End With
' Clean up Set objMessage = Nothing Set objConfig = Nothing Set Fields = Nothing
MsgBox "Email sent successfully using TLS." End Sub
Key Points: 1. TLS Port: Port `587` is typically used for TLS. Ensure your SMTP server supports this port. 2. Disable SSL: The `.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl")` property should be set to `False` for TLS. 3. Enable TLS: Use `.Item("http://schemas.microsoft.com/cdo/configuration/smtpusetls") = True` to explicitly enable TLS.
If your email provider does not specifically require `.smtpusetls`, using port `587` with `.smtpusessl = True` often negotiates TLS automatically. Ensure the server supports the protocol and authentication method you are trying to use.
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Email Seminar Lessons.
The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.