Sample code for 30+ languages & platforms
PureBasic

Transition from MailMan.FetchSingleHeaderByUidl to MailMan.FetchByUidl

Provides instructions for replacing deprecated FetchSingleHeaderByUidl method calls with FetchByUidl.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkEmail.pb"
IncludeFile "CkMailMan.pb"

Procedure ChilkatExample()

    success.i = 0

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

    ; ...
    ; ...

    numBodyLines.i = 5
    uidl.s = "123"

    ; ------------------------------------------------------------------------
    ; The FetchSingleHeaderByUidl method is deprecated:

    emailObj.i = CkMailMan::ckFetchSingleHeaderByUidl(mailman,numBodyLines,uidl)
    If CkMailMan::ckLastMethodSuccess(mailman) = 0
        Debug CkMailMan::ckLastErrorText(mailman)
        CkMailMan::ckDispose(mailman)
        ProcedureReturn
    EndIf

    ; ...
    ; ...

    CkEmail::ckDispose(emailObj)

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

    headerOnly.i = 1

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

    success = CkMailMan::ckFetchByUidl(mailman,uidl,headerOnly,numBodyLines,emailOut)
    If success = 0
        Debug CkMailMan::ckLastErrorText(mailman)
        CkMailMan::ckDispose(mailman)
        CkEmail::ckDispose(emailOut)
        ProcedureReturn
    EndIf



    CkMailMan::ckDispose(mailman)
    CkEmail::ckDispose(emailOut)


    ProcedureReturn
EndProcedure