ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Communication / Managing emails
  • Properties specific to Email variables
  • Correspondence between the properties and the RFC standard
  • WLanguage functions
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
The Email type is used to handle the email content as well as the associated information. You can define and change the characteristics of an email using different WLanguage properties.
This type replaces and extends the Email structure by giving you the ability to handle several messages at the same time.
Note: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
Example
// Envoi d'un email

// Construction du message
MonMessage is Email
// Expéditeur
MonMessage.Sender = sExpediteur
// Destinataires
sDestinataire_1 is string = "aaa@gmail.com"
sDestinataire_2 is string = "bbb@gmail.com"
Add(MonMessage.Recipient, sDestinataire_1)
Add(MonMessage.Recipient, sDestinataire_2)
// Contenu du message
MonMessage.Subject = SAI_Sujet
MonMessage.Message = RTFToText(sNote)
MonMessage.HTML = RTFToHTML(sNote)

// Ouverture une session SMTP
MaSession is emailSMTPSession
MaSession.ServerAddress = sServeur
IF EmailStartSession(MaSession) = False THEN RETURN

// Envoi du message (la constante emailOptionEncodeEntête permet
// de prendre en compte les caractères accentués)
EmailSendMessage(MaSession, MonMessage, emailOptionEncodeHeader)

// Fermeture de la session
EmailCloseSession(MaSession)
Properties

Properties specific to Email variables

The following properties can be used to handle Email variables:
NameType usedEffect
AsynchronousEmailIdentifierCharacter stringEmail identifier (asynchronous mode only).
WEBDEV only
WINDEVLinuxAndroidAndroid Widget iPhone/iPad This property is not available.
AttachArray of emailAttachContains the description of attached files.
The number of attached files is unlimited.
For more details, see emailAttach.
Note: If the attachment is filled in manually, don't forget to specify the Nom property, otherwise the image will not be transmitted in the email.. Example:
oEmail.Attach[1].Contenu = fLoadBuffer(fDataDir() +
	 ["\"] + "Email\" + sLogoSociété)
oEmail.Attach[1].ContentType = "image/gif"
oEmail.Attach[1].Nom = "logo.gif"
BccArray of character stringsContains the addresses of unofficial recipients: their names do not appear in the email received by official recipients (property Recipient).
The addresses are limited to 127 characters. The number of non-official recipients is limited to 200. This limit can be exceeded in SMTP mode. However, some servers do not support the emails with an important number of recipients.
CategoryCharacter stringList of keywords associated with the email. The keywords are separated by semicolons.
Note: If one of the keywords contains special characters or accents, use the constant emailOptionEncodeEntête when sending the message with the EmailSendMessage function.
CcArray of character stringsContains the addresses of recipients in copy: their names appear in the email received by official recipients (property Recipient).
The addresses are limited to 127 characters.
The number of recipients in copy is limited to 200. This limit can be exceeded in SMTP mode. However, some servers do not support the emails with an important number of recipients.
CertificateCertificateCertificate used to sign the email (header, content and attachments) before sending it.
LinuxAndroidAndroid Widget iPhone/iPad This property is not available.
DispositionNotificationBooleanOutbound, used to request a confirmation that the email was read by the recipient (True). The recipient does not necessarily have to send a read receipt.
Inbound, used to find out whether a read receipt was requested by the sender (True) or not.
If a read receipt is requested, it has priority over the delivery receipt.
This property is set to False by default.
WINDEVWEBDEV - Server code This property is not supported in Lotus Notes.
This property is supported by Outlook in Windows.
HeaderArray of emailHeaderHeaders of email.
HTMLCharacter stringMessage with HTML formatting. Limited to 4 GB.
This property is supported in POP3/SMTP only.
IDCharacter stringUnique email identifier. This identifier remains constant for the entire email lifetime. This identifier is initialized when sending the email (EmailSendMessage).
Note: If the identifier contains special characters or accents, use the constant emailOptionEncodeEntête when sending the message with the EmailSendMessage function.
WINDEVWEBDEV - Server code This property is supported by the Outlook messaging and by the Lotus Notes messaging only.
MessageCharacter stringText of message (with simple text formatting). Limited to 2 GB (64 KB for Lotus Notes).
Remarks:
  • If the message contains special characters or accented characters, use the constant emailOptionEncodeHeader when the message is sent by EmailSendMessage.
  • It is recommended not to exceed 98 characters per line in the body of the message. If a line exceeds 98 characters, the message may be classified as spam.
MessageIDCharacter stringUnique email identifier. This identifier remains constant for the entire email lifetime. This identifier is used to follow a conversation.
When sending an email, this variable specifies the email identifier. If this variable corresponds to an empty string, the identifier will be given by the server. The application that generates the identifier must check whether this identifier is unique.
When receiving an email, this variable specifies the email identifier.
This identifier must have the following format: <Identifier@domain>. For example: 1@192.168.2.210
WINDEVWEBDEV - Server code This property is not supported in Lotus Notes.

WINDEVWEBDEV - Server code This property is not supported by Outlook in Windows.
OutBooleanSpecifies whether a message was read on the server:
  • False if the message was read.
  • True if the message was not read.
PlainTextCharacter stringPlain text of message. This variable is available for the incoming emails only.
PriorityInteger constantType of priority for the email. The possible values are as follows:
  • emailPriorityLow: used, for example, for very low-urgency emails.
  • emailPriorityHigh: used, for example, for urgent emails.
  • emailNormalPriority (default): used for non-urgent emails, for example.
ReceiveDateCharacter string or DateTime variableDate when the message was received.
RecipientArray of character stringsContains the addresses of main recipients. The number of recipients is limited to 20.
This limit can be exceeded in SMTP mode. However, some servers do not support the emails with an important number of recipients.
ReferenceCharacter stringUnique identifier of one or more reference emails linked to the current conversation.
WINDEVWEBDEV - Server code This property is not supported in Lotus Notes.
WINDEVWEBDEV - Server code This property is not supported by Outlook in Windows.
ReturnAddressErrorCharacter stringReturn address if an error occurred. This address is managed by the POP3, IMAP and SMTP protocols. For more details, see Correspondence between the properties and the RFC standard.
Note: If the address contains special characters or accents, use the constant emailOptionEncodeEntête when sending the message with the EmailSendMessage function.
AndroidAndroid Widget Not available.
ReturnReceiptBooleanOutbound, used to request a delivery receipt from the recipient (True). The recipient does not necessarily have to send a delivery receipt.
Inbound, used to find out whether a delivery receipt was requested by the sender (True) or no (False). If a read receipt is requested, it has priority over the delivery receipt.
This property is set to False by default.
WINDEVWEBDEV - Server code This property is not supported by Outlook in Windows.
SenderCharacter stringSender email address. This address must be valid.
A sender name can be given in addition to the email address.. This name will be displayed in priority to the email address in an email application or webmail.. This property then uses the following format:
"<Nom> <adresse@domaine.com>"
Note: If the sender contains special characters or accents, use the constant emailOptionEncodeEntête when sending the message with the EmailSendMessage function.
WINDEVWEBDEV - Server code In Outlook, this variable is ignored. The name of account for the current session is used to fill this variable.
WINDEVWEBDEV - Server code In Lotus, the Lotus login is used if the sender is not specified.
SenderAddressCharacter stringAddress to which the answer to the message will be sent (up to 127 characters). Corresponds to Reply-To. For more details, see Correspondence between the properties and the RFC standard.
Note: If the address contains special characters or accents, use the constant emailOptionEncodeEntête when sending the message with the EmailSendMessage function.
WINDEVWEBDEV - Server code In Outlook, this variable is ignored. The name of account for the current session is used to fill this variable.
WINDEVWEBDEV - Server code In Lotus, the Lotus login is used if the sender is not specified.
SensitivityInteger constantType of confidentiality for the email. The possible values are as follows:
  • emailConfidential: Used, for example, for emails sent within a company..
  • emailNormal (Default): No confidentiality.
  • emailPersonnel: Used, for example, for personal emails.
  • emailPrivé: Used, for example, for private emails.
This property is not supported in Lotus Notes.
SignatureInteger constantStatus of email signature:
  • certificateExpired: Valid signature but certificate expired.
  • certificateInvalid: Invalid signature or certificate.
  • untrusted certificate: Valid signature but certificate's trusted root is untrusted.
  • certificateOK: Reliable signature and certificate.
This property is read-only.
LinuxAndroidAndroid Widget iPhone/iPad This property is not available.
SourceCharacter stringContains the source of incoming message (subject, sender, recipient, content, ...).
WINDEVWEBDEV - Server code This property is not supported by Outlook in Windows.
SubjectCharacter stringMessage subject.
Note: If the subject contains special characters or accents, use the constant emailOptionEncodeEntête when sending the message with the EmailSendMessage function.

Note: Non-Latin characters can be used in the following properties: Subject, Message, Category, Senderaddress, Sender, ID. In this case, use the constant emailOptionEncodeHeader when the message is sent by EmailSendMessage.
Remarks

Correspondence between the properties and the RFC standard

Version 23 and earlier
From version 24
OutgoingIncomingOutgoingIncoming
From Sender propertyPopulates the Sender property.Sender propertyPopulates the Sender property.
Reply-ToSenderAddress propertyPopulates the SenderAddress property.SenderAddress propertyPopulates the SenderAddress property.
Return-PathSenderAddress propertyPopulates the SenderAddress property if "Reply-To" is empty.ReturnAddressError propertyPopulates the ReturnAddressError property.
Return-Receipt-To (ReturnReceipt)SenderAddress if specified, Sender property otherwise.Sets the ReturnReceipt property to True if the received value is not empty.SenderAddress if specified, Sender property otherwise. Sets the ReturnReceipt property to True if the received value is not empty.
Disposition-Notification-To (DispositionNotification)SenderAddress if specified, Sender property otherwise. Sets the DispositionNotification property to True if the received value is not empty.SenderAddress if specified, Sender property otherwise. Sets the DispositionNotification property to True if the received value is not empty.

WLanguage functions

The following functions can be used to handle Email variables:
EmailBuildSourceGenerates the source code of the email message to be sent from the variables in the Email structure or in an Email variable.
EmailChangeStatusChanges the status of an email on a messaging server.
EmailCopyCopies an email found in a directory to another directory of an IMAP server.
EmailDeleteMessageDeletes the current email using the current protocol (POP3, IMAP, MS Exchange, Lotus Notes or Outlook).
EmailGetIndicatorRetrieves the indicators defined on an email of IMAP session.
EmailImportHTMLImports, into the Email structure or into an Email variable, the content of an HTML file in order to send it by email.
EmailImportSourcePopulates an Email variable using the content of its Source property or the different variables of the email structure using the content of the Email.Source variable.
EmailLoadAttachmentAdds an attached file to an email.
EmailReadFirstReads the first incoming email according to the protocol used (POP3 or IMAP, MS Exchange, Lotus Notes or Outlook).
EmailReadFirstHeaderReads the header of the first incoming email according to the protocol used (POP3 or IMAP, Lotus Notes or Outlook).
EmailReadLastReads the last incoming email according to the protocol used (POP3 or IMAP, MS Exchange, Lotus Notes or Outlook).
EmailReadLastHeaderReads the header of the last email received, depending on the protocol used (POP3 or IMAP, Lotus Notes or Outlook)..
EmailReadMessageReads an incoming according to the protocol used (POP3 or IMAP, Lotus Notes or Outlook).
EmailReadMessageHeaderReads the header of an incoming email according to the protocol used (POP3 or IMAP, Lotus Notes or Outlook).
EmailReadNextReads the incoming email found after the current email according to the protocol (POP3 or IMAP, MS Exchange, Lotus Notes or Outlook).
EmailReadNextHeaderReads the header of the email found after the current email according to the protocol used (POP3 or IMAP, Lotus Notes or Outlook).
EmailReadPreviousReads the email found before the current email according to the protocol used (POP3 or IMAP, MS Exchange, Lotus Notes or Outlook).
EmailReadPreviousHeaderReads the header of the email found before the current email according to the protocol used (POP3 or IMAP, Lotus Notes or Outlook).
EmailResetResets all the variables of the email structure or all the variables of an Email variable.
EmailSeekFirstFinds one or more emails according to the criteria specified in the messaging software (Outlook, messaging software using the IMAP protocol, ...).
EmailSeekFirstNotesSeeks one or more emails according to specified criteria, in a local or remote Lotus Notes or Domino database.
EmailSendMessageSends an email using a given protocol (SMTP, MS Exchange, Lotus Notes, Outlook).
Related Examples:
WD Mail Complete examples (WINDEV): WD Mail
[ + ] This application is an email client developed in WINDEV. It is based on the Email objects.
This email client is used to retrieve and send emails by using the POP, IMAP and SMTP protocols.
You have the ability to apply filters to the incoming emails.

The application can also be used to manage several email accounts. The writing of an email is based on the HTML edit control.
Minimum version required
  • Version 15
This page is also available for…
Comments
WEBDEV EMAIL
// btn_enviar ( popup)(server) // SMTP
MINHA_SESSAO is emailSMTPSession
MINHA_SESSAO..ServerAddress="smtpserver"
MINHA_SESSAO..Name="nome_usuario"
MINHA_SESSAO..Password="senha"
IF EmailStartSession(MINHA_SESSAO)=False THEN
ToastDisplay("smtp com erro",toastLong,vaMiddle,haCenter,ErrorInfo())
RETURN
END
//EMAIL
EMAIL_DADOS is Email
EMAIL_DADOS..Sender=EDT_Remetente
EMAIL_DADOS..Subject=EDT_Assunto
EMAIL_DADOS..HTML=EDT_HTML
EMAIL_DADOS..Message=HTMLToText(EDT_HTML)
EMAIL_DADOS..Recipient[1]=EDT_Destinatario
// ENVIAR EMAIL
IF EmailSendMessage(MINHA_SESSAO,EMAIL_DADOS)=False THEN
ToastDisplay("ERRO MENSAGEM",ErrorInfo())
ELSE
ToastDisplay("MENSAGEM ENVIADA COM SUCESSO")
END
// FECHAR SESSAO
EmailCloseSession(MINHA_SESSAO)
amarildo
15 Oct. 2020
Exemplo ok
PROCEDURE SendMensagem()

// Start an SMTP session
MySession is an emailSMTPSession
MySession..ServerAddress = "smtp.gmail.com"
MySession..Name = "adrianoboller@gmail.com"
MySession..Password = "senhasecreta"
MySession..Port = "587"
MySession..Asynchronous = True
IF EmailStartSession(MySession) = True

// Build an email
MyMessage is an Email
MyMessage..Sender = EDT_E_Mail
Add(MyMessage..Recipient, "adrianoboller@gmail.com")
MyMessage..Subject = EDT_Assunto
MyMessage..Message = EDT_Nome + " " + EDT_Telefone + " " + EDT_E_Mail + " " + EDT_Mensagem

// Send the message
IF EmailSendMessage(MySession, MyMessage) = True

ToastDisplay("E-mail enviado com sucesso!")

PAGE_Contato..Plane = 1

ELSE

ToastDisplay("Erro ao tentar enviar o e-mail!")

END

ELSE

ToastDisplay("Erro ao tentar enviar o e-mail!")

END
BOLLER
28 Sep. 2018
ERRO CERTIFICACAO ARRUMADO
EmailConfigure(emailParameterMode,1)
// ESSA CONFIGURACAO ACIMA ARRUMA ERRO CERTIFICACAO
EmailSetTimeOut(30)
HourGlass()
n_email_sessao is boolean=EmailStartSMTPSession(EDT_USUARIO,EDT_SENHA,EDT_SERVIDOR_SMTP,EDT_porta,False,emailOptionSecuredTLS)
IF n_email_sessao=True THEN
_minha_mensagem is an Email // est un Email
_minha_mensagem..Sender=EDT_EmailSender
Add(_minha_mensagem..Recipient, EDT_destinatario)
_minha_mensagem..Subject = EDT_ASSUNTO
_minha_mensagem..Message = EDT_MENSAGEM
_minha_mensagem..SenderAddress = EDT_EmailSender
_minha_mensagem..ReturnReceipt = True
EmailLoadAttachment(_minha_mensagem,EDT_anexo)
IF EmailSendMessage(EDT_USUARIO, _minha_mensagem) = False THEN
Info("Erro Mandar Mesnagem:"+CR+ErrorInfo())
END
EmailCloseSession(EDT_USUARIO)
END
HourGlass(False)
// blog com video e exemplo
// http://windevdesenvolvimento.blogspot.com.br/2017/10/aula-1277-email-3-erro-certificacao.html
// https://www.youtube.com/watch?v=LxqfFegkGqo

De matos
29 Oct. 2017

Last update: 09/20/2024

Send a report | Local help