Note: Any Chilkat method that returns a reference to an object will return a NULL reference upon failure. You should always check for NULL before dereferencing the object (i.e. before trying to use it).
Here are examples in various programming languages for the mailman.CopyMail method (which downloads email from a POP3 server and returns an EmailBundle object):
C#:
Chilkat.EmailBundle bundle = null;
bundle = mailman.CopyMail();
if (bundle == null ) {
MessageBox.Show(mailman.LastErrorText);
return;
}
VB.NET:
Dim bundle As Chilkat.EmailBundle
bundle = mailman.CopyMail()
If (bundle Is Nothing ) Then
MsgBox(mailman.LastErrorText)
Exit Sub
End If
C++:
CkEmailBundle *bundle = 0;
bundle = mailman.CopyMail();
if (bundle == 0 ) {
printf("%s\n",mailman.lastErrorText());
return;
}
VB6:
Dim bundle As ChilkatEmailBundle2
Set bundle = mailman.CopyMail()
If (bundle Is Nothing ) Then
MsgBox mailman.LastErrorText
Exit Sub
End If
Delphi:
bundle := mailman.CopyMail();
if (bundle = nil ) then
begin
ShowMessage(mailman.LastErrorText);
end;
Foxpro:
loBundle = loMailman.CopyMail()
IF (loBundle = NULL ) THEN
=MESSAGEBOX(loMailman.LastErrorText)
QUIT
ENDIF
SQL Server Stored Procedure:
DECLARE @bundle int
EXEC sp_OAMethod @mailman, 'CopyMail', @bundle OUT
IF @bundle Is NULL
BEGIN
EXEC sp_OAGetProperty @mailman, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
RETURN
END
Ruby:
bundle = mailman.CopyMail()
if (bundle == nil )
print mailman.lastErrorText() + "\n"
exit
end
Perl:
$bundle = $mailman->CopyMail();
if ($bundle eq null ) {
print $mailman->lastErrorText() . "\n";
exit;
}
Python:
bundle = mailman.CopyMail()
if (bundle == None ):
print mailman.lastErrorText()
sys.exit()
Java:
CkEmailBundle bundle;
bundle = mailman.CopyMail();
if (bundle == null ) {
System.out.println(mailman.lastErrorText());
return;
}
Classic ASP:
Set bundle = mailman.CopyMail()
If (bundle Is Nothing ) Then
Response.Write mailman.LastErrorText & ""
End If