Sample code for 30+ languages & platforms
PowerBuilder

Send an SMTP RSET Command

See more SMTP Examples

Demonstrates the Chilkat MailMan.SmtpReset method, which sends an SMTP RSET command to the server. RSET resets the server-side state of the current mail transaction. This example opens a connection, sends RSET, and closes.

Background: During an SMTP session a message is built up across MAIL FROM and RCPT TO commands. If you need to abandon that partially-specified transaction — say an error occurred midway — RSET clears it without dropping the connection, so the same authenticated session can start a fresh message. It's a lightweight way to recover in-session rather than reconnecting.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Mailman

li_Success = 0

//  Demonstrates the MailMan.SmtpReset method, which sends an SMTP RSET command to the server.
//  RSET resets the server-side state of the current mail transaction.

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"

//  Open the connection.

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

//  Reset the current SMTP mail transaction.
li_Success = loo_Mailman.SmtpReset()
if li_Success = 0 then
    Write-Debug loo_Mailman.LastErrorText
    destroy loo_Mailman
    return
end if

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

Write-Debug "Sent SMTP RSET."


destroy loo_Mailman