【发布时间】:2026-02-05 15:20:02
【问题描述】:
有没有办法从区域或缓冲区构建电子邮件消息,设置收件人,然后以 elisp 代码发送消息?
我已将 emacs 配置为通过我的 gmail account 发送邮件,并且我希望能够从 elisp 程序向自己发送电子邮件。使用的命令是message-mail。
【问题讨论】:
有没有办法从区域或缓冲区构建电子邮件消息,设置收件人,然后以 elisp 代码发送消息?
我已将 emacs 配置为通过我的 gmail account 发送邮件,并且我希望能够从 elisp 程序向自己发送电子邮件。使用的命令是message-mail。
【问题讨论】:
这是一个消息邮件的包装器,它会提示您输入“收件人”和“主题”行:
(defun my-message-mail-region (b e to subject)
"Send the current region in an email"
(interactive "r\nsRecipient: \nsSubject: ")
(let ((orig-buffer (current-buffer)))
(message-mail to subject)
(message-goto-body)
(insert (save-excursion (set-buffer orig-buffer)
(buffer-substring-no-properties b e)))
(message-send-and-exit)))
【讨论】:
In mail-region: init.el:48:3:Warning: Use 'with-current-buffer' rather than save-excursion+set-buffer