Skip to content Skip to sidebar Skip to footer

Extracting Different Content-type Of Mht File Into Multiple Mht File

I am writing an mht script to parse an mht file and extract the part message from the parent and write them to a separate mht file I wrote the below function which opens a mht file

Solution 1:

Try this:

...
if m['Content-type'].startswith('text/'):
                    m["Content-Transfer-Encoding"] = "quoted-printable"else:
                    m["Content-Transfer-Encoding"] = "base64"

                m.set_payload(part.get_payload())                        
                ****Writing to output****
                info = part.as_string(unixfrom=False)
                info = info.replace('application/octet-stream', 'text/plain')
                output.write(info)
...

Tell me if it works.

Post a Comment for "Extracting Different Content-type Of Mht File Into Multiple Mht File"