From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: ding@gnus.org
Subject: Re: using templates to write articles (email)
Date: Fri, 10 Jun 2011 11:53:25 -0700 [thread overview]
Message-ID: <87ei318qmy.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <87fwnhd0mx.fsf@yun.yagibdah.de>
lee <lee@yun.yagibdah.de> writes:
> Hi,
>
> is there some sort of support built into gnus for writing articles
> (email) from templates? Such templates would contain either headers or a
> body, or a combination of both.
>
> So far, I´ve created templates as plain text files, and when writing an
> email from the template, I delete everything in the composing buffer and
> do an insert-file to read the template into the buffer. This works fine,
> and perhaps there´s some support for templates already built in, which
> would make using templates more convenient?
I don't know of anything built in, but I wrote the following function to
do something like a mail merge. It's very primitive, but could serve as
the basis for what you need.
--8<---------------cut here---------------start------------->8---
(defun my-mail-merge (names buffer subject from marker)
"This is a bit of a mess, but it's something like a mail merge.
Variable containing names should be a list of two-element lists,
in the format (\"Name\" \"email address\")."
(interactive "XVariable containing names: \nbBuffer to slurp: \nsSubject: \nsFrom: \nsMarker: ")
(dolist (n names)
(compose-mail (nth 1 n) ; to address
subject
`(("From" . ,from)) ; all other headers
nil nil nil nil) ; don't remember
(insert-buffer-substring (get-buffer buffer))
(message-goto-body)
(perform-replace marker (nth 0 n) nil nil nil) ; insert name
(message-send-and-exit)))
--8<---------------cut here---------------end--------------->8---
"marker" here is basically just something like XXXXX, that gets replaced
with the name. The logical next step would be to have it read data from
a file instead of a variable, and then have the top line of the file set
the markers for each field, like so:
{{name}},{{salutation}},{{email}}
John Doe,Dear,j.doe@gmail.com
Then use those markers in a template, and have the call to
perform-replace loop once for each marker.
Hope that provides food for thought,
Eric
next prev parent reply other threads:[~2011-06-10 18:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-10 18:03 lee
2011-06-10 18:53 ` Eric Abrahamsen [this message]
2011-06-10 20:41 ` lee
2011-06-10 19:32 ` Didier Verna
2011-06-10 20:46 ` lee
2011-06-11 17:22 ` Dan Christensen
2011-06-13 0:33 ` solved: " lee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ei318qmy.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--cc=ding@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).