Sample code for 30+ languages & platforms
Go

Extract Files from MIME

See more MIME Examples

Extract files from a MIME message.

Chilkat Go Downloads

Go
    success := false

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    mime := chilkat.NewMime()

    // Load a MIME document from a file:
    // (.mht and .eml files contain MIME).
    success = mime.LoadMimeFile("mst.mht")
    if success == false {
        fmt.Println(mime.LastErrorText())
        mime.DisposeMime()
        return
    }

    st := chilkat.NewStringTable()
    success = mime.PartsToFiles("/temp/mimeParts",st)
    if success == false {
        fmt.Println(mime.LastErrorText())
        mime.DisposeMime()
        st.DisposeStringTable()
        return
    }

    n := st.Count()

    // Display the paths of the files created:
    i := 0
    for i < n {
        fmt.Println(*st.StringAt(i))
        i = i + 1
    }


    mime.DisposeMime()
    st.DisposeStringTable()