ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

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
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Allows you to delete the current email via a specific protocol:
  • POP3 protocol: the email is deleted from the email server.
  • IMAP protocol: the email is flagged as "erased/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.
  • WEBDEV - Server code MS Exchange client: the email is deleted from the in-box of messages.
  • WEBDEV - Server code Lotus Notes or Outlook mail: the email is deleted from the in-box of messages.
After the call to EmailDeleteMessage, the Email.Out variable is positioned to True.
Reminder: Before reading or deleting an email, you need to start a session with EmailStartSession (for POP3 and MS Exchange), with EmailStartNotesSession (for Lotus Notes) or with EmailStartOutlookSession or OutlookStartSession (for Outlook).
Linux The POP3 protocol can only be used to delete emails.
cMySession is emailIMAPSession
...
IF EmailStartSession(cMySession) THEN
cMyEmail is Email
EmailReadFirst(cMySession, cMyEmail)
WHILE NOT cMyEmail.Out
EmailDeleteMessage(cMySession, cMyEmail)
EmailReadNext(cMySession, cMyEmail)
END
EmailCloseSession(cMySession)
END
// Use with the Outlook messaging software
// TABLE_EmailTable table contains all the incoming emails
// COL_Sender contains the sender name (Email.Sender variable)
// COL_Subject contains the email subject (Email.Sujet variable)
// COL_ID contains the email identifier (Email.ID variable)
// Delete the selected email from the Table control
EmailDeleteMessage(SessionID, 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:
<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.
WEBDEV - Server codeWindowsAjax

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 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 <Message number> 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.
Caution: Gmail via a POP3 session: when using EmailDeleteMessage, the email is flagged as deleted but it is not deleted. It is the standard operating mode of Gmail via POP3.
WEBDEV - Server codeWindowsAjax

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: wd290com.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 07/05/2023

Send a report | Local help