AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Comunicación / Gestión de correos electrónicos
  • Timeout
  • Connection with two-factor authentication
  • Gmail: What should I do if a connection to Gmail (SMTP, IMAP, POP3) fails due to a certificate error?
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Starts a session for receiving and reading emails with the IMAP protocol. You will only be able to read the emails. You have the ability to start a secure IMAP session via SSL.
Note To open an email session, use the EmailStartSMTPSession function.
Ejemplo
// Read an email via the IMAP protocol
IF EmailStartIMAPSession(EDT_USER, EDT_PASSWORD, "imap.mydomain.fr") = True THEN
	ProcessIncomingEmails()
ELSE
	Error("Unable to establish the connection")
END
Sintaxis
<Result> = EmailStartIMAPSession(<Username> , <Password> , <Server address> [, <Port> [, <Option>]])
<Result>: Boolean
  • True if the session was started,
  • False otherwise. To get the details of the error, use ErrorInfo.
<Username>: Character string
Username on the server. This name is supplied by the service provider or by the network administrator. This name will be used to identify the email session in the different functions for email management.
<Password>: Character string or Secret string
User password. This password is given by the service provider or by the network administrator.
Novedad versión 2025
Cadenas secretas: Si utiliza el almacén de cadenas secretas, el tipo de cadena secreta utilizado para este parámetro debe ser "ANSI o Unicode string".
Para obtener más información sobre las cadenas secretas y el almacén, consulte Almacén de cadenas secretas.
Novedad versión 2025
AndroidWidget Android Las cadenas secretas no están disponibles para este parámetro en aplicaciones Android y widgets de Android.
<Server address>: Character string
Address of email server (incoming protocol). This address is supplied by the service provider or by the network administrator. This address can be specified as follows:
  • IP address in XXX.XXX.XXX.XXX format (192.168.1.1 for example).
  • IP address containing the server name (imap.mydomain.fr for example). This syntax is recommended.
  • IP address returned by NetIPAddress.
Note: The address must be an IPv4 address.
<Port>: Optional integer
Identifies the port used for the IMAP protocol (143 by default).
<Option>: Optional Integer constant
Used to specify whether an SSL connection is required:
emailOptionDefault
(Default value)
Non-secure connection.
optionTLSTLS connection required (for a secure IMAP server).
Note The port generally used for a secure IMAP server is 993 (not 143, the default port value).
Before version 28 Update 4, this constant was named optionSSL.
Observaciones

Timeout

The timeout can be set using EmailSetTimeOut.

Connection with two-factor authentication

More and more providers offer secure email accounts (SMTP/IMAP) with two-factor authentication.
Here's how it works:
  • OAuth connection to the mailbox provider: this connection provides a token.
  • Use the token to connect to IMAP or SMTP email boxes.
Let's see an example of code that can be used:
// Example of IMAP connection with a Gmail account
// and two-factor authentication
OAuthGoogleCnt is OAuth2Parameters
gMyIMAPSession is emailIMAPSession

// IMAP server parameters
gMyIMAPSession.ServerAddress = "imap.gmail.com"
gMyIMAPSession.Option = optionTLS
MyIMAPSession.Port = "993"

// OAuth connection parameters
OAuthGoogleCnt.ClientID = "Application ID"
OAuthGoogleCnt.ClientSecret = "Secret application ID"
OAuthGoogleCnt.AuthURL = "https://accounts.google.com/o/oauth2/auth"
OAuthGoogleCnt.TokenURL = "https://accounts.google.com/o/oauth2/token"
OAuthGoogleCnt.Scope = "https://mail.google.com/"
OAuthGoogleCnt.RedirectionURL = "http://localhost:9000"
OAuthGoogleCnt.ResponseType = "code"

// OAuth authentication
gMyIMAPSession.AuthToken = AuthIdentify(OAuthGoogleCnt)
// If the authentication was successful, log in to email inbox.
IF gMyIMAPSession.AuthToken <> Null THEN
	// prefix syntax of EmailStartSession
	IF gMyIMAPSession.StartSession() THEN
	// Session started
	ELSE
	// Error starting the session.
	END
ELSE
	// Authentication error.
END

Gmail: What should I do if a connection to Gmail (SMTP, IMAP, POP3) fails due to a certificate error?

Since the end of August 2017, Google has deployed a new certificate: Google Internet Authority G3. Unfortunately, the Windows API for checking certificates does not validate this certificate.
Therefore, starting a POP3, IMAP or SMTP session may fail with the error "The certificate string was not issued by a trusted authority".
To validate the certificate, all you have to do is modify the management mode of emails. The WLanguage EmailConfigure function allows you to change this mode and to no longer use the Windows API that locks this certificate. The following code must be added before starting the session via EmailStartIMAPSession:
// Enable the multi-platform implementation
EmailConfigure(emailParameterMode, 1)
Remarks:
  • As of version 23 Update 1, you no longer need to call the EmailConfigure function: WLanguage automatically uses the email management mode appropriate to the session.
  • You can handle certificate errors on an SMTP session using the IgnoreError property of a variable of type emailSMTPSession.
Componente: wd300com.dll
Versión mínima requerida
  • Versión 15
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 16/05/2025

Señalar un error o enviar una sugerencia | Ayuda local