Sample code for 30+ languages & platforms
DataFlex

Clear the SMTP Session Log

See more SMTP Examples

Demonstrates the Chilkat MailMan.ClearSmtpSessionLog method, which clears the current contents of the SmtpSessionLog property. This example opens an SMTP connection (which populates the log) and then clears it.

Background: Like its POP3 counterpart, the SmtpSessionLog records the raw client/server dialog — the EHLO, AUTH, MAIL FROM, RCPT TO, and DATA exchanges — which is the first thing to inspect when a send fails. Clearing it between sends keeps the captured log focused on the operation you care about rather than the entire history of a reused MailMan object.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoMailman
    String sTemp1

    Move False To iSuccess

    //  Demonstrates the MailMan.ClearSmtpSessionLog method, which clears the current contents of
    //  the SmtpSessionLog property.

    Get Create (RefClass(cComChilkatMailMan)) To hoMailman
    If (Not(IsComObjectCreated(hoMailman))) Begin
        Send CreateComObject of hoMailman
    End

    //  Configure the SMTP server connection.
    Set ComSmtpHost Of hoMailman To "smtp.example.com"
    Set ComSmtpPort Of hoMailman To 465
    Set ComSmtpSsl Of hoMailman To True
    Set ComSmtpUsername Of hoMailman To "user@example.com"
    Set ComSmtpPassword Of hoMailman To "myPassword"

    //  Perform an SMTP operation, which populates the session log.

    Get ComOpenSmtpConnection Of hoMailman To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoMailman To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    //  Clear the SMTP session log (for example, before the next operation).
    Send ComClearSmtpSessionLog To hoMailman

    Get ComCloseSmtpConnection Of hoMailman To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoMailman To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln "SMTP session log cleared."


End_Procedure