Android™
Android™
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 Android™ Downloads
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;
import android.app.Activity;
import com.chilkatsoft.*;
import android.widget.TextView;
import android.os.Bundle;
public class SimpleActivity extends Activity {
private static final String TAG = "Chilkat";
// Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
boolean success = false;
// Demonstrates the MailMan.ClearSmtpSessionLog method, which clears the current contents of
// the SmtpSessionLog property.
CkMailMan mailman = new CkMailMan();
// Configure the SMTP server connection.
mailman.put_SmtpHost("smtp.example.com");
mailman.put_SmtpPort(465);
mailman.put_SmtpSsl(true);
mailman.put_SmtpUsername("user@example.com");
mailman.put_SmtpPassword("myPassword");
// Perform an SMTP operation, which populates the session log.
success = mailman.OpenSmtpConnection();
if (success == false) {
Log.i(TAG, mailman.lastErrorText());
return;
}
// Clear the SMTP session log (for example, before the next operation).
mailman.ClearSmtpSessionLog();
success = mailman.CloseSmtpConnection();
if (success == false) {
Log.i(TAG, mailman.lastErrorText());
return;
}
Log.i(TAG, "SMTP session log cleared.");
}
static {
System.loadLibrary("chilkat");
// Note: If the incorrect library name is passed to System.loadLibrary,
// then you will see the following error message at application startup:
//"The application <your-application-name> has stopped unexpectedly. Please try again."
}
}