Accessing the body a message programatically

classic Classic list List threaded Threaded
3 messages Options
Alan Schmitt Alan Schmitt
Reply | Threaded
Open this post in threaded view
|

Accessing the body a message programatically

Hello,

I need to extract some information from a message that is shown in
notmuch-mode, and I was able to easily get the from and subject of the
message. I now need to use the body, but I cannot find how to get it. I
assume I should use notmuch-get-bodypart-text, but I don't know how to
obtain the msg or part argument.

In addition, can I get access to the List-Archive header? I could do it
by spawning an external process to get the raw message, but it seems a
bit heavy handed.

Thanks,

Alan

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch

signature.asc (497 bytes) Download Attachment
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: Accessing the body a message programatically

Alan Schmitt <[hidden email]> writes:

> Hello,
>
> I need to extract some information from a message that is shown in
> notmuch-mode, and I was able to easily get the from and subject of the
> message. I now need to use the body, but I cannot find how to get it. I
> assume I should use notmuch-get-bodypart-text, but I don't know how to
> obtain the msg or part argument.
>

If you mean interactively for a currently displayed message, have a look
at the function notmuch-show-current-part-handle, and the way it uses
notmuch-show-get-{message,part}-properties.

> In addition, can I get access to the List-Archive header? I could do it
> by spawning an external process to get the raw message, but it seems a
> bit heavy handed.

there is a couple of patches by Johan Parin currently under review
to provide a configurable set of headers. You can find them via

https://nmbug.notmuchmail.org/status/#Review
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Alan Schmitt Alan Schmitt
Reply | Threaded
Open this post in threaded view
|

Re: Accessing the body a message programatically

On 2019-12-17 09:34, David Bremner <[hidden email]> writes:
>
> If you mean interactively for a currently displayed message, have a look
> at the function notmuch-show-current-part-handle, and the way it uses
> notmuch-show-get-{message,part}-properties.

This is great, thanks. Here is what I did:

(defun as/notmuch-get-body ()
  (let* ((msg (notmuch-show-get-message-properties))
         (part (notmuch-show-get-part-properties)))
    (notmuch-get-bodypart-text msg part nil)))

>> In addition, can I get access to the List-Archive header? I could do it
>> by spawning an external process to get the raw message, but it seems a
>> bit heavy handed.
>
> there is a couple of patches by Johan Parin currently under review
> to provide a configurable set of headers. You can find them via
>
> https://nmbug.notmuchmail.org/status/#Review

I'll have a look.

Thanks again,

Alan

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch

signature.asc (497 bytes) Download Attachment