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

Transition from Imap.FetchChunk to Imap.FetchRange

Provides instructions for replacing deprecated FetchChunk method calls with FetchRange.

Chilkat Go Downloads

Go
    success := false

    imap := chilkat.NewImap()

    //  ...
    //  ...

    startSeqNum := 1
    count := 5

    failedSet := chilkat.NewMessageSet()
    fetchedSet := chilkat.NewMessageSet()

    //  ------------------------------------------------------------------------
    //  The FetchChunk method is deprecated:

    bundleObj := imap.FetchChunk(startSeqNum,count,failedSet,fetchedSet)
    if imap.LastMethodSuccess() == false {
        fmt.Println(imap.LastErrorText())
        imap.DisposeImap()
        failedSet.DisposeMessageSet()
        fetchedSet.DisposeMessageSet()
        return
    }

    //  ...
    //  ...

    bundleObj.DisposeEmailBundle()

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

    headersOnly := false

    bundleOut := chilkat.NewEmailBundle()
    success = imap.FetchRange(headersOnly,startSeqNum,count,bundleOut)
    if success == false {
        fmt.Println(imap.LastErrorText())
        imap.DisposeImap()
        failedSet.DisposeMessageSet()
        fetchedSet.DisposeMessageSet()
        bundleOut.DisposeEmailBundle()
        return
    }


    imap.DisposeImap()
    failedSet.DisposeMessageSet()
    fetchedSet.DisposeMessageSet()
    bundleOut.DisposeEmailBundle()