Integer hoMailMan
Get Create (RefClass(cComChilkatMailMan)) to hoMailMan
            
Integer iRetVal
Get ComUnlockComponent of hoMailMan "..." to iRetVal
If (not(iRetVal)) Begin
    // error
    Procedure_Return
End
            
Set ComMailHost of hoMailMan to "host"
Set ComMailPort of hoMailMan to 995
Set ComPopSsl of hoMailMan to True
Set ComStartTLS of hoMailMan to True
            
Set ComPopUsername of hoMailMan to "username"
Set ComPopPassword of hoMailMan to "password" 
            
Integer hoEmailBundle
Get Create (RefClass(cComChilkatEmailBundle)) to hoEmailBundle
Variant vEmailBundle
            
Get ComCopyMail of hoMailMan to vEmailBundle
Set pvComObject of hoEmailBundle to vEmailBundle                       
If (IsNullComObject(vEmailBundle)) Begin
    String sErrorText
    Get ComLastErrorText of hoMailMan to sErrorText
    Send Info_Box sErrorText                
End
Else Begin            
    Integer iLoop
    For iLoop from 0 to (ComMessageCount(hoEmailBundle)-1)
        Integer hoEmail
        Variant vEmail
                    
        Get ComGetEmail of hoEmailBundle iLoop to vEmail
                    
        Get Create (RefClass(cComChilkatEmail)) to hoEmail
        Set pvComObject of hoEmail to vEmail
                    
        Showln (ComSubject(hoEmail)) 
                    
        Send Destroy to hoEmail
    Loop   
End
            
Send Destroy to hoMailMan