Closed robert-winkler closed 3 years ago
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import os
import tempfile
import mimetypes
from email import policy
from email.parser import BytesParser
raw = sys.stdin.buffer.read()
msg = BytesParser(policy=policy.default).parsebytes(raw)
text = str(msg.get('From'))
myCmd = 'echo "From: ' + text + '"| abook --add-email-quiet'
print(myCmd)
os.system(myCmd)
does the job!
@robert-winkler if you want you can contribute and explain your abook "integration" in the wiki.
@robert: if you are using python anyway you might just as well define a hook
and extract the existing Email object from the ui (see the wiki for many such examples)
instead of calling pipeto
..
Quoting Lucas Hoffmann (2021-04-17 10:04:49)
@robert-winkler if you want you can contribute and explain your abook "integration" in the wiki.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.*
Thanks for your comments! I documented the hook in the wiki. @patrick (pazz): Yes, I should learn how to avoid the pipetos..; but I started with an example and once having a working code I don't touch it anymore.
Quoting Patrick Totzke (2021-04-18 04:36:40)
@robert: if you are using python anyway you might just as well define a hook and extract the existing Email object from the ui (see the wiki for many such examples) instead of calling
pipeto
..Quoting Lucas Hoffmann (2021-04-17 10:04:49)
@robert-winkler if you want you can contribute and explain your abook "integration" in the wiki.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.*
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.*
Hi, the abook integration of alot is great. This method is a lot faster than notmuch requests, and the contacts can be manually maintained. Basically, it is very easy to add a new address from command line:
However, I tried simple
:pipeto
and some python scripts (bound to a key), for adding the Sender (From:) of an open email to the abook, but don't find a working solution. Has anyone managed such semi-automated contact management? Also code snipplets to get the header fields would be extremely helpful...