Skip to content

Saving Message to PDF with Attachment Names #2117

@Richard-CAID

Description

@Richard-CAID

I do not program, but use emacs extensively and find mu4e to be a great asset in my charity-based work with Indigenous People ( a lot of correspondence is involved). I need to get messages to "save to pdf" with attachment names to trim my work
flow down (I currently print-to-pdf from Thunderbird). I have message "save to pdf" working after installing wkhtmltopdf with the following in my dotspacemacs user init:

(defun mu4e-action-save-to-pdf (msg)
(let* ((date (mu4e-message-field msg :date))
(infile (mu4e~write-body-to-html msg))
(outfile (format-time-string "%Y-%m-%d%H%M%S.pdf" date)))
(with-temp-buffer
(shell-command
(format "wkhtmltopdf %s ~/Desktop/Email/%s" infile outfile) t))))
(add-to-list 'mu4e-view-actions '("Save to PDF" . mu4e-action-save-to-pdf) t)

I was able to add Cc to the "save to pdf" by adding the following in my mu4e-actions.el under mu4e~write-body-to-html:

  (insert (concat "<strong>Cc</strong>: " (mu4e~action-header-to-html msg :cc) "</br>"))

I attempted to have attachment names saved with the message "save to pdf" by adding the following under mu4e~write-body-to-html:

  (insert (concat "<strong>Attachments</strong>: " (mu4e-message-field msg :attachment) "</p>"))

The heading "Attachments: "is within the message pdf, but not the name of the attachment(s). I have attached examples of what I have so far with saving to pdf as apposed to printing to pdf from Thunderbird. My system is:

OS Opensuse Tumbleweed
Emacs (Spacemacs) is v. 27.2
Mu4e is mu for emacs version 1.4.15

How do I set for attachments names to be included in "save to pdf"?

2021_08_20_TBird_Redacted.pdf
2021_08_20_mu4e_Redacted.pdf

Metadata

Metadata

Assignees

No one assigned

    Labels

    mu4especific for mu4erfe

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions