Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mime-extractor: write subject and text #236

Open
c0de9en opened this issue Feb 22, 2022 · 0 comments
Open

mime-extractor: write subject and text #236

c0de9en opened this issue Feb 22, 2022 · 0 comments

Comments

@c0de9en
Copy link

c0de9en commented Feb 22, 2022

It would be nice to write message text to files. Same as in this patch.

index 2313bc4..974e0ec 100644
--- a/cmd/mime-extractor/mime-extractor.go
+++ b/cmd/mime-extractor/mime-extractor.go
@@ -81,6 +81,29 @@ func (ex *extractor) extract(file, dir string) int {
 
        // Write errOut attachments
        fmt.Fprintf(ex.errOut, "\nExtracting attachments into %s...", dir)
+
+       // Write Subject
+       newFileName := filepath.Join(dir, ".subject")
+       err = ex.fileWrite(newFileName, []byte(e.GetHeader("Subject")), 0644)
+       if err != nil {
+               fmt.Fprintf(ex.stdOut, "Error writing file %q: %v\n", newFileName, err)
+       }
+
+       // Write TEXT
+       newFileName = filepath.Join(dir, ".text")
+       err = ex.fileWrite(newFileName, []byte(e.Text), 0644)
+       if err != nil {
+               fmt.Fprintf(ex.stdOut, "Error writing file %q: %v\n", newFileName, err)
+       }
+
+       // Write HTML
+       newFileName = filepath.Join(dir, ".html")
+       err = ex.fileWrite(newFileName, []byte(e.HTML), 0644)
+       if err != nil {
+               fmt.Fprintf(ex.stdOut, "Error writing file %q: %v\n", newFileName, err)
+       }
+
+       // Write attachments
        for _, a := range e.Attachments {
                newFileName := filepath.Join(dir, a.FileName)
                err = ex.fileWrite(newFileName, a.Content, 0644)

I use this patch. May be other users need something the same...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant