mime-extractor: write subject and text
c0de9en opened this issue · comments
c0de9en commented
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...