Send emails by calling SMTP Server directly (1 Viewer)

JohnPapa

Registered User.
Local time
Tomorrow, 00:16
Joined
Aug 15, 2010
Messages
954
I can use MS Access to send emails using an email client like MS Outlook.

I could not find any way for MS Access to send emails directly to the SMTP server, essentially bypassing MS Outlook or any other email client.

Is this possible?
 

JohnPapa

Registered User.
Local time
Tomorrow, 00:16
Joined
Aug 15, 2010
Messages
954
I tried the following, but unfortunately does not send. The xxx, were replaced for valid email addresses.

It tells me "The transport failed to connect to the server"

What should I put in

config.Fields(cdoSMTPServer).value

Should I put the Outgoing Server of my ISP? I believe I placed the correct server name.

Code:
    Dim mail    As CDO.message
    Dim config  As CDO.Configuration
  
    Set mail = CreateObject("CDO.Message")
    Set config = CreateObject("CDO.Configuration")
  
    config.Fields(cdoSendUsingMethod).value = cdoSendUsingPort
    config.Fields(cdoSMTPServer).value = "xxx"
    config.Fields(cdoSMTPServerPort).value = 587   '25
    config.Fields.update
  
    Set mail.Configuration = config
  
    With mail
        .To = "xxx@xxx.org"
        .From = "xxx@xxx.com"
        .Subject = "First email with CDO"
        .TextBody = "This is the body of the first plain text email with CDO."
      
        '.AddAttachment "C:\path\to\a\file.dat"
      
        .send
    End With
  
    Set config = Nothing
    Set mail = Nothing
 

ebs17

Well-known member
Local time
Today, 23:16
Joined
Feb 7, 2020
Messages
1,986
Some SMTP servers require authentication before allowing a connection. Research in this direction.
 

JohnPapa

Registered User.
Local time
Tomorrow, 00:16
Joined
Aug 15, 2010
Messages
954
Some SMTP servers require authentication before allowing a connection. Research in this direction.
Will look into what you mention.

I tried to send an email using ISP icdSoft. I used

Code:
    config.Fields(cdoSendUsingMethod).value = cdoSendUsingPort
    config.Fields(cdoSMTPServer).value = "mail.s427.sureserver.com"
    config.Fields(cdoSMTPServerPort).value = 587
    config.Fields.update

icdSoft specifies the following

Incoming and outgoing serverProtocolPortInformation
mail.s427.sureserver.comIMAPS993IMAP with SSL/TLS encryption
POP3S995POP3 with SSL/TLS encryption
SMTP587Supports SSL/TLS encryption with STARTTLS
SMTPS465SMTP with SSL/TLS encryption
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:16
Joined
Sep 21, 2011
Messages
14,465
@isladogs dogs has a CDO Email tester app

 

JohnPapa

Registered User.
Local time
Tomorrow, 00:16
Joined
Aug 15, 2010
Messages
954
Some SMTP servers require authentication before allowing a connection. Research in this direction.
You were correct. Needs authentication, at least with my ISP.
 

JohnPapa

Registered User.
Local time
Tomorrow, 00:16
Joined
Aug 15, 2010
Messages
954
@isladogs dogs has a CDO Email tester app

I downloaded the example you mention, I ran it. Nothing happens when I click on any of the buttons "Send Email", "Help", "Quit"
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:16
Joined
Sep 21, 2011
Messages
14,465
Works for me, just using Plain Text as it initially loads??
 

JohnPapa

Registered User.
Local time
Tomorrow, 00:16
Joined
Aug 15, 2010
Messages
954
No warnings. I will check the trusted location.
It was a problem with the trusted location. I would have expected a message. It now gives one of the errors which appear in the documentation.
 

Users who are viewing this thread

Top Bottom