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
  • Principle
  • Read an email (variable of type Email): The different stages
  • Example
  • Reading an Email (Email structure): The different stages
  • Example
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
Principle
This help page explains how to read an email from a WINDEV application and how to display its content in a WINDEV application.
The email is read by several WLanguage functions (EmailReadFirst, EmailReadNext, ...).
The content of the email can be retrieved:
  • in a variable of type Email. The Email variables allow you to handle several emails simultaneously.
  • via the Email structure. The variables of this structure contain the informations regarding the email read.
The variables of Email structure (as well as the properties of Email variables) correspond to the email characteristics.
Read an email (variable of type Email): The different stages
The steps for reading an email in WLanguage are as follows:
  1. Use a function for reading emails to browse all the emails of a messaging session, several syntaxes are available:
    • Perform a loop such as:
      MySession is emailPOP3Session
      MyMessage is Email
      EmailReadFirst(MySession, MyMessage)
      WHILE NOT MyMessage.Out
      // Insert the message process
      EmailReadNext(MySession, MyMessage)
      END
    • Retrieve all the messages in an array with EmailGetAll:
      MySession is emailPOP3Session
      MyMessages is array of Email = EmailGetAll(MySession)

      Remarks:
      • When using the POP3 protocol, the incoming emails that can be read are the emails that have been received when the session was started. All the emails received once the session is started are not "visible". To access the new incoming emails, the session must be closed and re-started.
      • To follow the reading progress, use EmailProgressBar.
  2. Read the content of the Email variable.
    Note: If the Email contains specific headers, they can be read using the Email type variable.
  3. If the HTML property is not empty: message is in HTML format. It must be displayed in a browser (see the example below).
    For each attached file:
    • Save the file on disk (EmailSaveAttachment).
    • Browse the HTML message and find the "cID:"+Identifier value of the attached file. Replace this value by the full path of attached file copied on disk.
      Display the message in a browser.
  4. If the HTML property is empty: the message is in text format.
  5. Save the attached files on disk if necessary and display the message text.

Example

MyMessage is Email
...
Temp_Dir is string = "C:\temp\"
CID is string
I is int
// For each attached file
Attachment is emailAttach
FOR EACH Attachment OF MyMessage.Attach
// Copy the file into a temporary directory
EmailSaveAttachment(Attachment, Temp_Dir + Attachment.Name)
// Retrieve the identifier of the attached file
CID ="cid:" + Attachment.Identifier
// Replace the references to the attached file by the real name of the file
MyMessage.HTML = Replace(MyMessage.HTML, CID, ...
"file:" + Temp_Dir + Attachment.Name)
END
// Display the HTML content in an HTML control
HTM_Display = MyMessage.HTML
Reading an Email (Email structure): The different stages
The steps for reading an email in WLanguage are as follows:
  1. Use a function for reading emails (EmailReadFirst, EmailReadNext, ...). To follow the reading progress, use EmailProgressBar.
  2. Read the content of the email structure (see the example below).
  3. If variable Email.HTML is not empty: message is in HTML format. It must be displayed in a browser.
    For each attached file (the Email.NbAttach variable is not empty):
    • Save the file on disk (EmailSaveAttachment).
    • Browse the HTML message and find the "cID:"+Email.AttachIdentifier value of the attached file. Replace this value by the full path of attached file copied on disk.
    • Display the message in a browser.
  4. If the Email.HTML variable is empty: the message is in text format.
  5. Save the attached files on disk if necessary and display the message text.
Note When using the POP3 protocol, the emails received that can be read are those received at the time the session is opened. All the emails received once the session is started are not "visible". To access the new incoming emails, the session must be closed and re-started.

Example

Temp_Dir is string = "C:\temp\"
CID is string
I is int

// For each attached file
FOR I = 1 TO Email.NbAttach
// Copy the file into a temporary directory
EmailSaveAttachment(Email.Attach[I], ...
Temp_Dir + Email.Attach[I])
// Retrieve the identifier of the attached file
CID = "cid:" + Email.AttachIdentifier[I]
// Replace the references to the attached file
// by the real name of the file
Email.HTML = Replace(Email.HTML, CID, "file:" + ...
Temp_Dir + Email.Attach[I])
END

// Display the HTML content in a Web browser
// Create a temporary file containing the HTML
FileName is string = Temp_Dir + "temp.htm"
hFile is int = fOpen(FileName, foCreate + foWrite)
fWrite(hFile, Email.HTML, Size(Email.HTML))
fClose(hFile)

// Supply the temporary file to the browser
// Web_Browser is an ActiveX control "Microsoft Web Browser"
Web_browser>>Navigate(FileName)
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/03/2025

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