Chilkat Examples

ChilkatHOMEAndroid™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi DLLGoJavaNode.jsObjective-CPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwiftTclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Examples
Web API Categories

AI
ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Box
CAdES
CSR
CSV
Cert Store
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Markdown
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
Regular Expressions
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
X
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(DataFlex) SMTP Inspection

See more SMTP Examples
Examine an SMTP session to view all communications sent to the SMTP server.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoMailman
    Variant vEmail
    Handle hoEmail
    String sMimeStr
    String sTemp1

    Move False To iSuccess

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

    Set ComSmtpHost Of hoMailman To "smtp.example.com"
    Set ComSmtpUsername Of hoMailman To "myUsername"
    Set ComSmtpPassword Of hoMailman To "myPassword"

    Set ComSmtpPort Of hoMailman To 465
    Set ComStartTLS Of hoMailman To True

    Get Create (RefClass(cComChilkatEmail)) To hoEmail
    If (Not(IsComObjectCreated(hoEmail))) Begin
        Send CreateComObject of hoEmail
    End

    Set ComSubject Of hoEmail To "This is a test"
    Set ComBody Of hoEmail To "This is a test"
    Set ComFrom Of hoEmail To "Alex <alex@example.com>"
    Get ComAddTo Of hoEmail "Christoph" "christoph@example2.com" To iSuccess
    Get ComAddBcc Of hoEmail "Victor" "victor@example3.com" To iSuccess

    // Generate the MIME that is sent when SendEmail is called
    Get pvComObject of hoEmail to vEmail
    Get ComRenderToMime Of hoMailman vEmail To sMimeStr
    Showln sMimeStr

    Get pvComObject of hoEmail to vEmail
    Get ComSendEmail Of hoMailman vEmail To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoMailman To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComCloseSmtpConnection Of hoMailman To iSuccess
    If (iSuccess <> True) Begin
        Showln "Connection to SMTP server not closed cleanly."
    End

    // Examine the SMTP session log.
    Showln "----"
    Showln "Smtp Session Log:"
    Get ComSmtpSessionLog Of hoMailman To sTemp1
    Showln sTemp1

    // ---------------------------------------------------
    // Sample output:
    // ---------------------------------------------------

    // MIME-Version: 1.0
    // Date: Fri, 06 Mar 2026 16:21:00 -0600
    // Message-ID: <A5DC25990C93EC2676F4FBB2BB3BFA9EB34FF9D3@CHILKAT25>
    // Content-Type: text/plain; charset=us-ascii; format=flowed
    // Content-Transfer-Encoding: 7bit
    // X-Priority: 3 (Normal)
    // Subject: This is a test
    // From: Alex <alex@example.com>
    // To: Christoph <christoph@example2.com>
    // Bcc: Victor <victor@example3.com>
    // 
    // This is a test
    // ----
    // Smtp Session Log:
    // 220 smtp.example.com ESMTP Amazon WorkMail SMTP Service
    // EHLO MYCOMPUTER<CRLF>
    // 250-smtp.example.com
    // 250-8BITMIME
    // 250-AUTH PLAIN LOGIN
    // 250 Ok
    // AUTH LOGIN<CRLF>
    // 334 VXNlcm5hbWU6
    // YWRtaW5AY2hpbGthdHNvZnQuY29t<CRLF>
    // 334 UGFzc3dvcmQ6
    // {PasswordOrCredentials}
    // 235 Authentication successful.
    // MAIL FROM:<alex@example.com><CRLF>
    // 250 Ok
    // RCPT TO:<christoph@example2.com><CRLF>
    // 250 Ok
    // RCPT TO:<victor@example3.com><CRLF>
    // 250 Ok
    // DATA<CRLF>
    // 354 End data with <CR><LF>.<CR><LF>
    // {388 bytes} <--- The MIME source of the email (examined via RenderToMime) was sent here.
    // <CRLF>.<CRLF>
    // 250 Ok
    // QUIT<CRLF>
    // 221 Bye


End_Procedure

 

© 2000-2025 Chilkat Software, Inc. All Rights Reserved.