This tip may be useful for people who are using Mutt in connection
with any kind of database like CRM Customer Relationship Management
systems.

I have made a mutt.desktop file in
~/.local/share/applications/mutt.desktop where I am designating a
script which is intercepting mailto: links that I usually click on the
website to contact people:

[Desktop Entry]
Version=1.0
Type=Application
Name=RCD Mutt
GenericName=Email Client
Comment=Mutt
Exec=/home/data1/protected/bin/rcd/rcd-mutt %U
Icon=mutt
Terminal=true
MimeType=x-scheme-handler/mailto;
StartupNotify=false
Categories=Application;


The script `rcd-mutt' basically parses the email address and asks the
user (me) about the group of people where I wish to sort that new
email address. It is recording the new email address into the database
before writing to it. Thus it creates relation to database objects. If
email already exists in the database, it just continues with Mutt.

As script is pretty customized for myself it will not give any useful
insight, but users can make such script in shell or any other
programming language.

Purpose of this explanation is to help users intercept the email
address and record it in a global address book before writing to it. 



#!/usr/bin/env -S clisp -norc
(load 
"/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/configure-system.lisp")
(load "/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/connect.lisp")
(load "/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/dbtools.lisp")
(load 
"/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/crmtools.lisp")
(load 
"/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/utilities.lisp")
(load 
"/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/shelltools.lisp")

(when *args*
  (let* ((email (string-trim '(#\Space #\Newline #\Tab) (car *args*)))
         (email (replace-all email "mailto:"; ""))
         (question-mark (search "?" email))
         (email (if question-mark (substring email 0 question-mark) email)))
     (when email
       (let ((id (rcd-crm-id-by-email email)))
        (if id
            (shell (format nil "mutt ~A" (car *args*)))
            (let ((account (shell-1st-result "rcd-sql-select.sh account")))
              (if account
                  (let ((email (sql-escape-string email)))
                    (rcd-sql (format nil "INSERT INTO people (people_lastname, 
people_account1, people_email1)
                                          VALUES (~A, ~A, ~A)" email account 
email))
                    (shell (format nil "mutt ~A" (car *args*))))
                  (shell (format nil "yad --center --text \"Could not find 
account for email ~R. ABORTING.\"" email)))))))))




Jean

Reply via email to