Sample code for 30+ languages & platforms
PureBasic Requires Chilkat v11.0.0+

Transition from Email.CreateDsn to Email.ToDsn

Provides instructions for replacing deprecated CreateDsn method calls with ToDsn.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkEmail.pb"

Procedure ChilkatExample()

    success.i = 0

    email.i = CkEmail::ckCreate()
    If email.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    ;  ...
    ;  ...

    explanation.s = "..."
    statusFieldsXml.s = "..."
    headerOnly.i = 0

    ;  ------------------------------------------------------------------------
    ;  The CreateDsn method is deprecated:

    emailObj.i = CkEmail::ckCreateDsn(email,explanation,statusFieldsXml,headerOnly)
    If CkEmail::ckLastMethodSuccess(email) = 0
        Debug CkEmail::ckLastErrorText(email)
        CkEmail::ckDispose(email)
        ProcedureReturn
    EndIf

    ;  ...
    ;  ...

    CkEmail::ckDispose(emailObj)

    ;  ------------------------------------------------------------------------
    ;  Do the equivalent using ToDsn.
    ;  Your application creates a new, empty Email object which is passed 
    ;  in the last argument and filled upon success.

    dsnEmail.i = CkEmail::ckCreate()
    If dsnEmail.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success = CkEmail::ckToDsn(email,explanation,statusFieldsXml,headerOnly,dsnEmail)
    If success = 0
        Debug CkEmail::ckLastErrorText(email)
        CkEmail::ckDispose(email)
        CkEmail::ckDispose(dsnEmail)
        ProcedureReturn
    EndIf



    CkEmail::ckDispose(email)
    CkEmail::ckDispose(dsnEmail)


    ProcedureReturn
EndProcedure