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
  • Using the POP3 protocol
  • Deleting messages and number of incoming messages (POP3 protocol)
  • Using MS Exchange Client, Lotus Notes or Outlook
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Allows you to delete the current email via a specific protocol:
  • POP3 protocol: Email is deleted directly from the mail server.
  • IMAP protocol: the Email is marked "deleted/deleted". It will be actually deleted from the email server during the next "expunge" command (clear the bin from a WebMail for example).
    You also have the ability to force the destruction of all deleted emails via EmailExpunge.
  • WINDEV MS Exchange client: the Email is deleted from the message box.
  • WINDEV Lotus Notes or Outlook email: the email is deleted from the message box.
After the call to EmailDeleteMessage, the Email.Out variable is positioned to True.
Reminder Before manipulating an Email (e.g. reading or deleting an Email), it is necessary to open a session with the EmailStartSession function (for the POP3 protocol, MS Exchange), with the EmailStartNotesSession function (for the Lotus Notes messaging software) or with the EmailStartOutlookSession or OutlookStartSession function (for the Outlook messaging software).
LinuxJava The POP3 protocol can only be used to delete emails.
cMaSession is emailIMAPSession
...
IF EmailStartSession(cMaSession) THEN 
	cMonEmail is Email
	EmailReadFirst(cMaSession, cMonEmail)
	WHILE NOT cMonEmail.Out
		EmailDeleteMessage(cMaSession, cMonEmail)
		EmailReadNext(cMaSession, cMonEmail)
	END
	EmailCloseSession(cMaSession)
END
// Utilisation avec le logiciel de messagerie Outlook 
// TABLE_TableEmail contient l'ensemble des emails reçus
// COL_Exp contient le nom de l'expéditeur (variable Email.Expéditeur)
// COL_Sujet contient le sujet de l'email (variable Email.Sujet)
// COL_ID contient l'identifiant de l'email (variable Email.ID)
// Suppression de l'email sélectionné dans le champ Table
EmailDeleteMessage(IDSession, COL_ID)
Syntax

Deleting an email by using the POP3 or IMAP protocol Hide the details

<Result> = EmailDeleteMessage(<Session> [, <Email or message number>])
<Result>: Boolean
  • True if the message was deleted,
  • False otherwise.
<Session>: Character string, or emailPOP3Session or emailIMAPSession variable
Identifies the user session. This parameter corresponds to:
Java emailPOP3Session and emailIMAPSession variables are not available.
<Email or message number>: Optional Email variable or integer
If this parameter is an Email variable, the message corresponding to the variable is deleted.
If this parameter is an integer, it identifies the number of the message to delete on the server.
If this parameter is not specified, the last message read is deleted from the email server.
WINDEVWindowsUser code (UMC)

Deleting an email received through MS Exchange, Lotus Notes or Outlook Hide the details

<Result> = EmailDeleteMessage(<Session> [, <Email or message identifier>])
<Result>: Boolean
  • True if the message was deleted,
  • False otherwise. To get more details on the error, use ErrorInfo with the errMessage constant.
<Session>: Integer or EmailOutlookSession variable
Identifier of the current email session. This value can be:
<Email or message identifier>: Optional Email variable or character string
If this parameter is an Email variable, the message corresponding to the variable is deleted.
If this parameter is a character string, it specifies the identifier of the message to delete on the server.
If the parameter is not specified, the last message read is deleted from the email server and the Email.out variable is set to True.
Remarks

Using the POP3 protocol

If <Message number>:
  • is not specified: the last message read is deleted from the Email server.
  • is specified: the message identified by <Numéro message> is deleted from the Email server.
When a message is deleted by EmailDeleteMessage:
  • The message will be actually deleted from the email server during the disconnection (EmailCloseSession).
  • The Email.Out variable is set to True.

Deleting messages and number of incoming messages (POP3 protocol)

If a message was deleted by EmailDeleteMessage:
  • EmailNbMessage returns the number of messages found on the email server before the deletion.
  • the message numbers are not re-assigned.
Therefore, if four messages are found on the server during the connection, these messages are numbered from 1 to 4. If message #1 is deleted:
  • EmailNbMessage (used in the same session) returns 4.
  • Message 1 cannot be read by EmailReadMessage because the message does not exist anymore (only messages 2, 3 and 4 exist).
The message numbers are re-assigned during the next connection.
Warning: Gmail via a POP3 session session: when using the EmailDeleteMessagefunction, the Email is marked as deleted but is not deleted. It is the standard operating mode of Gmail via POP3.
WINDEVWindowsUser code (UMC)

Using MS Exchange Client, Lotus Notes or Outlook

The last message read is deleted from the incoming messages. This message will not be displayed anymore when the messages are browsed by EmailReadFirst and EmailReadNext.
After the call to EmailDeleteMessage, the Email.Out variable is positioned to True.
To recover deleted items, go the deleted items folder of MS Exchange, Lotus Notes or 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.
The POP3 Email functions Unit examples (WINDEV): The POP3 Email functions
[ + ] Using the Email functions to manage the POP3 protocol.
This protocol is used to retrieve emails from a server.
Business / UI classification: Business Logic
Component: wd300com.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help