Sample code for 30+ languages & platforms
Chilkat2-Python

Extract Files from MIME

See more MIME Examples

Extract files from a MIME message.

Chilkat Chilkat2-Python Downloads

Chilkat2-Python
import sys
import chilkat2

success = False

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

mime = chilkat2.Mime()

# Load a MIME document from a file:
# (.mht and .eml files contain MIME).
success = mime.LoadMimeFile("mst.mht")
if (success == False):
    print(mime.LastErrorText)
    sys.exit()

st = chilkat2.StringTable()
success = mime.PartsToFiles("/temp/mimeParts",st)
if (success == False):
    print(mime.LastErrorText)
    sys.exit()

n = st.Count

# Display the paths of the files created:
i = 0
while i < n :
    print(st.StringAt(i))
    i = i + 1