Sample code for 30+ languages & platforms
Xojo Plugin

Get JSON Details from the Last MailMan Call

See more SMTP Examples

Demonstrates the Chilkat MailMan.GetLastJsonData method, which copies any structured JSON details produced by the immediately preceding method call into a JsonObject. Not every MailMan method produces JSON details, and the method must be called immediately after the call of interest. This example sends an email and then retrieves the JSON details.

Tip: JSON parsing code for this result can be generated at Chilkat Tools.

Background: Some Chilkat methods gather structured diagnostic information alongside their normal result — details that are more useful as data than as a log string. GetLastJsonData exposes that as a JsonObject you can query programmatically. Because it reflects only the most recent call, retrieve it right away: any subsequent MailMan method may replace it.

Chilkat Xojo Plugin Downloads

Xojo Plugin
Dim success As Boolean
success = False

//  Demonstrates the MailMan.GetLastJsonData method, which copies any structured JSON details
//  produced by the immediately preceding method call into a JsonObject.  Not every MailMan
//  method produces JSON details, and it must be called immediately after the method of
//  interest.

Dim mailman As New Chilkat.MailMan

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

//  Send an email.
Dim email As New Chilkat.Email
email.Subject = "Test email"
email.From = "alice@example.com"
success = email.AddTo("Bob","bob@example.com")
email.Body = "Hello!"
success = mailman.SendEmail(email)
If (success = False) Then
    System.DebugLog(mailman.LastErrorText)
    Return
End If

//  Immediately retrieve any JSON details produced by the send.
Dim json As New Chilkat.JsonObject
mailman.GetLastJsonData json
System.DebugLog(json.Emit())

//  JSON parsing code for this result can be generated at Chilkat's online tool:
//  https://tools.chilkat.io/jsonParse

//  Note: Explicitly connecting/authenticating is optional.  Chilkat MailMan automatically
//  connects and authenticates -- using the property settings above -- whenever a server
//  operation requires it.  Calling the explicit connect/authenticate methods can still be
//  helpful to determine whether a failure occurs while connecting or while authenticating.