Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Mailman

li_Success = 0

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

loo_Mailman = create oleobject
li_rc = loo_Mailman.ConnectToNewObject("Chilkat.MailMan")
if li_rc < 0 then
    destroy loo_Mailman
    MessageBox("Error","Connecting to COM object failed")
    return
end if

//  Configure the SMTP server connection.
loo_Mailman.SmtpHost = "smtp.example.com"
loo_Mailman.SmtpPort = 465
loo_Mailman.SmtpSsl = 1
loo_Mailman.SmtpUsername = "user@example.com"
loo_Mailman.SmtpPassword = "myPassword"

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

li_Success = loo_Mailman.OpenSmtpConnection()
if li_Success = 0 then
    Write-Debug loo_Mailman.LastErrorText
    destroy loo_Mailman
    return
end if

//  Clear the SMTP session log (for example, before the next operation).
loo_Mailman.ClearSmtpSessionLog()

li_Success = loo_Mailman.CloseSmtpConnection()
if li_Success = 0 then
    Write-Debug loo_Mailman.LastErrorText
    destroy loo_Mailman
    return
end if

Write-Debug "SMTP session log cleared."


destroy loo_Mailman