- Properties specific to the description of Email variables
- Correspondence between the properties and the RFC standard
- WLanguage functions
Email (Type of variable) In french: Email
The Email type is used to handle the email content as well as the associated information. The characteristics of an email can be defined and changed using different WLanguage properties. This type replaces and extends the Email structure by allowing, for example, to handle several messages at the same time. Remark: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable. Versions 17 and later New in version 17 Versions 21 and later New in version 21 Versions 22 and later New in version 22
// 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)
Remarks Properties specific to the description of Email variables The following properties can be used to handle an Email variable: | | | Name | Type used | Effect |
---|
Versions 23 and laterAsynchronousEmailIdentifier New in version 23AsynchronousEmailIdentifier AsynchronousEmailIdentifier | Character string | Email identifier (asynchronous mode only). WEBDEV only | Attache | Array of emailAttach | Contains the description of attached files. The number of attached files is unlimited. For more details, see emailAttach.Remark: If the file is attached manually, do not forget to specify the Name property, otherwise the image will not be sent along with the email. Example:
oEmail.Attache[1].Contenu = fLoadBuffer(fDataDir() + ["\"] + "Email\" + sLogoSociété) oEmail.Attache[1].ContentType = "image/gif" oEmail.Attache[1].Nom = "logo.gif"
| Bcc | Array of character strings | Contains the addresses of non-official recipients: their name is not displayed in the email received by the official recipients (Recipient property). 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. | Category | Character string | List of keywords associated with the email. The keywords are separated by semicolons.Remark: If one of the keywords contains special characters or accented characters, use the constant emailOptionEncodeHeader when the message is sent by EmailSendMessage. | Cc | Array of character strings | Contains the addresses of recipients in copy: their name is displayed in the email received by the official recipients (Recipient property). 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. | Versions 16 and laterCertificate New in version 16Certificate Certificate | Certificate | Certificate used to sign the email (header, content and attachments) before sending it. Versions 16 and later New in version 16 | Confidentialité | Integer constant | Type of confidentiality for the email. The possible values are as follows:- emailCompanyConfidential: Used for the in-house emails for example.
- emailNoSensitivity (Default value): No confidentiality.
- emailPersonal: Used for the personal emails for example.
- emailPrivate: Used for the private emails for example.
This property is not supported in Lotus Notes. | DispositionNotification | Boolean | Outbound, 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 return receipt. This property is set to False by default. This Property is managed by Outlook under Windows. | Versions 19 and laterHeader New in version 19Header Header | Array of emailHeader | Headers of email. | HTML | Character string | Message with HTML formatting. Limited to 4 GB. This property is supported in POP3/SMTP only. | ID | Character string | Unique email identifier. This identifier remains constant for the entire email lifetime. This identifier is initialized when sending the email (EmailSendMessage).Remark: If the identifier contains special characters or accented characters, use the constant emailOptionEncodeHeader when the message is sent by EmailSendMessage. | Message | Character string | Text of message (with simple text formatting). Limited to 2 GB (64 KB for Lotus Notes).Remark: If the message contains special characters or accented characters, use the constant emailOptionEncodeHeader when the message is sent by EmailSendMessage. | MessageID | Character string | Unique 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
| Out | Boolean | Specifies whether a message was read on the server: - False if the message was read.
- True if the message was not read.
| PlainText | Character string | Plain text of message. This variable is available for the incoming emails only. | Priority | Integer constant | Type of priority for the email. The possible values are as follows:- emailLowPriority: used for the really non-urgent emails.
- emailHighPriority: used for the urgent emails.
- emailNormalPriority (Default value): used for the non-urgent emails.
| ReceiveDate | Character string or DateTime variable | Date when the message was received. | Recipient | Array of character strings | Contains 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. | Reference | Character string | Unique identifier of one or more reference emails linked to the current conversation.
| Versions 24 and laterReturnAddressError New in version 24ReturnAddressError ReturnAddressError | Character string | Return 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. Remark: If the address contains special characters or accented characters, use the constant emailOptionEncodeHeader when the message is sent by EmailSendMessage. | ReturnReceipt | Boolean | Outbound, 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 return receipt. This property is set to False by default. | Sender | Character string | Address of sender. This address must be a unique, valid email address. For more details, see Correspondence between the properties and the RFC standard.Remark: If the sender contains special characters or accented characters, use the constant emailOptionEncodeHeader when the message is sent by EmailSendMessage. | SenderAddress | Character string | Address 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.Remark: If the address contains special characters or accented characters, use the constant emailOptionEncodeHeader when the message is sent by EmailSendMessage. | Versions 16 and laterSignature New in version 16Signature Signature | Integer constant | Status of email signature: - certificateExpired: Valid signature but expired certificate.
- certificateInvalid: Invalid signature or certificate.
- certificateUntrusted: Valid signature but untrusted certificate root.
- certificateOK: Trusted signature and certificate.
This property is available in read-only mode. Versions 16 and later New in version 16 | Source | Character string | Contains the source of incoming message (subject, sender, recipient, content, ...). | subject | Character string | Message subject. Remark: If the subject contains special characters or accented characters, use the emailOptionEncodeHeader constant when the message is sent by EmailSendMessage. |
Versions 17 and laterRemark: You can use non-Latin characters in the following properties: Subject, Message, Category, SenderAddress, Sender, ID. In this case, use the constant emailOptionEncodeHeader when the message is sent by EmailSendMessage. New in version 17Remark: You can use non-Latin characters in the following properties: Subject, Message, Category, SenderAddress, Sender, ID. In this case, use the constant emailOptionEncodeHeader when the message is sent by EmailSendMessage. Remark: You can use non-Latin characters in the following properties: Subject, Message, Category, SenderAddress, Sender, ID. In this case, use the constant emailOptionEncodeHeader when the message is sent by EmailSendMessage.Correspondence between the properties and the RFC standard | | | | | | Version 23 and earlier | From version 24 | | Envoi | Reception | Envoi | Reception | From | Sender property | Populates the Sender property. | Sender property | Populates the Sender property. | Reply-To | SenderAddress property | Populates the SenderAddress property. | SenderAddress property | Populates the SenderAddress property. | Return-Path | SenderAddress property | Populates the SenderAddress property if "Reply-To" is empty. | Property AddressReturnError | Populates the ReturnAddressError property. | Return-Receipt-To (ReturnReceipt) | Property Sender address if filled, otherwise Property Sender. | Sets True the Property Acknowledgement if the received value is not empty. | Property AddressSender if filled, otherwise Property Sender. | Sets True the Property Acknowledgement if the received value is not empty. | Disposition-Notification-To (DispositionNotification) | Property AddressSender if filled, otherwise Property Sender. | Sets True the Property ConfirmationRead if the value received is not empty. | Property AddressSender if filled, otherwise Property Sender. | Sets True the Property ConfirmationRead if the value received is not empty. |
WLanguage functions The following functions can be used to handle an Email variable:
| | EmailChangeStatus | Changes the status of an email on a messaging server. | EmailLoadAttachment | Adds an attached file to an email. | EmailSeekFirst | Finds one or more emails according to the criteria specified in the messaging software (Outlook, messaging software using the IMAP protocol, ...). | EmailSeekFirstNotes | Seeks one or more emails according to specified criteria, in a local or remote Lotus Notes or Domino database. | EmailBuildSource | Generates the source code of the email message to be sent from the variables in the Email structure or in an Email variable. | EmailCopy | Copies an email found in a directory to another directory of an IMAP server. | EmailSendMessage | Sends an email using a given protocol (SMTP, MS Exchange, Lotus Notes, Outlook). | EmailImportHTML | Imports, into the Email structure or into an Email variable, the content of an HTML file in order to send it by email. | EmailImportSource | Populates 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. | EmailReadLast | Reads the last incoming email according to the protocol used (POP3 or IMAP, MS Exchange, Lotus Notes or Outlook). | EmailReadLastHeader | Reads the header of last incoming email according to the protocol used (POP3 or IMAP, Lotus Notes or Outlook). | EmailReadMessageHeader | Reads the header of an incoming email according to the protocol used (POP3 or IMAP, Lotus Notes or Outlook). | EmailReadPreviousHeader | Reads the header of the email found before the current email according to the protocol used (POP3 or IMAP, Lotus Notes or Outlook). | EmailReadFirstHeader | Reads the header of the first incoming email according to the protocol used (POP3 or IMAP, Lotus Notes or Outlook). | EmailReadNextHeader | Reads the header of the email found after the current email according to the protocol used (POP3 or IMAP, Lotus Notes or Outlook). | EmailReadMessage | Reads an incoming according to the protocol used (POP3 or IMAP, Lotus Notes or Outlook). | EmailReadPrevious | Reads the email found before the current email according to the protocol used (POP3 or IMAP, MS Exchange, Lotus Notes or Outlook). | EmailReadFirst | Reads the first incoming email according to the protocol used (POP3 or IMAP, MS Exchange, Lotus Notes or Outlook). | EmailReadNext | Reads the incoming email found after the current email according to the protocol (POP3 or IMAP, MS Exchange, Lotus Notes or Outlook). | EmailReset | Resets all the variables of the email structure or all the variables of an Email variable. | EmailGetIndicator | Retrieves the indicators defined on an email of IMAP session. | EmailDeleteMessage | Allows you to delete the current Email according to the current protocol (POP3, IMAP, MS Exchange, Lotus Notes or Outlook). |
Related Examples:
|
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.
|
This page is also available for…
|
|
|
| |
| | // 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)
|
|
|
|
| |
| |
| |
|
| | 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 |
|
|
|
| |
| |
| |
|
| 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
|
|
|
|
| |
| |
| |
| |
| |
| |
| | |
|