Tags: mail

RSS - Atom - Subscribe via email

Setting e-mail expectations: Roughly once a week

Posted: - Modified: | communication, connecting

hamster-wheelI’ve seen the e-mail hamster-wheel that other people are stuck on, and I don’t want to go there. As for me, e-mail doesn’t make me feel important or needed or valued. E-mail is… well… it’s conversations that are hidden from the world, thoughts that I’m going to forget because no one else is going to come across them in a search engine and post comments. As lots of people have observed (including Luis Suarez, whom I knew at IBM): “E-mail is where knowledge goes to die.”

Still, e-mail is useful. I keep e-mail for following up with clients, coordinating with W- or with meetup organizers, introducing people, handling quick tech support for my mom, and answering the occasional private question that usually doesn’t have to be private anyway. I like getting quick questions, especially if I can send people links (although getting those questions as public comments works even better!). I like getting in-depth questions too, which I try to answer in blog posts whenever possible, add a note to my outline with the name of the person requesting it.

I reply to e-mail roughly once a week, although I check it more often to see if there’s anything that needs attention. Here’s how I work. Maybe you’ll pick up some ideas or tips! =)

I use my phone to quickly check e-mail while I’m walking or waiting. I get a lot of e-mail that I don’t particularly care about, even though I periodically unsubscribe from lists. The phone’s limited interface means that I generally don’t use it to reply to e-mail (unless I can say what I need in one or two sentences with no links), but I can delete unneeded messages and add stars to messages that need action.

Friday is my “catch up” day. I balance my company books, follow up on tasks I’m waiting for, and go through my e-mail, writing blog posts (like this one!) and e-mailing replies. The Share a Draft plugin for WordPress helps here because I can keep my ~1-post-a-day schedule while still giving people a sneak preview of any upcoming blog posts related to their question.

If there are important conversations I need to follow up on, I use Boomerang for Gmail. This archives the message for now, returning it to my inbox in case I haven’t received a reply within the specified timeframe. I also use Boomerang for Gmail’s “Send Later” feature to schedule e-mails so that I don’t have to set a reminder.

There are lots of other ways that people handle e-mail. There’s the idea of “Touch it once” – check mail only when you’re ready to handle it, and move important information to your to-do list. That would probably mean checking it more frequently, though, and I don’t want to commit time every day to do that. There’s being strict about checking only at specified times (such as once a day, or even once a week) and always having an Out of Office message turned on or putting that in your signature, but that felt odd too.  So here we are – I check mail frequently, respond occasionally, and try to move things into blog posts as much as possible.

There are trade-offs for my approach, of course. I could probably drum up more business and build more connections if I had a reputation for being instantly responsive… but I wouldn’t want to be shackled to my e-mail and I wouldn’t want my task list to be rearranged with every incoming message, so I’m fine with what I have.

Also, if it takes you a few weeks to reply too, no need to apologize. Almost all of my mail isn’t time-sensitive, and if it’s important to me, I’ll indicate the date I need a response by and I’ll follow up if time has passed.

E-mail doesn’t have to be a slave-driver. =)

Analyzing my Lotus Notes sent mail since January 2011

| analysis, ibm, lotus

Today is my penultimate day at IBM! Having successfully turned my projects over to another developer (hooray for the habit of organizing project-related files in Lotus Connections Activities), I’ve been focusing on getting things ready for the traditional goodbye e-mail, which I plan to send tomorrow.

I dug around in the Lotus Connections Profiles API to see if I could get a list of my contacts’ e-mail addresses. I fixed a small bug in the feed exporter of the Community Toolkit (w4.ibm.com/community for people in the IBM intranet) and exported my contacts, giving me a list of 530 IBMers who had accepted or sent me an invitation to connect.

Not everyone participates in that Web 2.0 network, though, so I wanted to analyze my sent mail to identify other people to whom I should send a note. I couldn’t find a neat LotusScript to do the job, and I couldn’t get the NSF to EML or mbox converter to work. Because I didn’t need all the information, just the recipients, subjects, and times, I wrote my own script (included at the end of this blog post).

I used the script to summarize the messages in my sent mail folder, and crunched the numbers using PivotTables in Microsoft Excel. I worked with monthly batches so that it was easier to find and fix errors. I decided to analyze all the mail going back to the beginning of last year in order to identify the people I mailed the most frequently, and to come up with some easy statistics as well.

image

Spiky around project starts/ends, I’d guess.

image

I wanted to see which roles I tended to e-mail often, so I categorized each recipient with their role. I distinguished between people I’d worked with directly on projects (coworkers) and people who worked with IBM but with whom I didn’t work on a project (colleagues). The numbers below count individual recipients.

Role

Number of people

Number of individual
e-mails sent

Average e-mails sent
per person

colleague 407 827 2.0
coworker 50 562 11.2
client 21 387 18.4
manager 4 109 27.3
partner 9 51 5.7
system 9 21 2.3
other 8 11 1.4
self 1 5 5.0
Grand Total 509 1973 3.9

As it turns out, I sent a lot of mail to a lot of people throughout IBM, mostly in response to questions about Lotus Connections, Idea Labs, or collaboration tools.

Now I can sort my summarized data to see whom I e-mailed the most often, and add more names to my don’t-forget-to-say-goodbye list. If all goes well, I might even be able to use that mail merge script. =)

The following agent processes selected messages and creates a table with one row per recipient, e-mailing the results to the specified mail address. It seems to choke on calendar entries and other weird documents, but if you go through your sent mail box in batches (Search This View by date is handy), then you should be able to find and delete the offending entries.

Option Public
Dim TempNitem As NotesItem
Dim TempNm As NotesName
Dim session As  NotesSession
Dim db As NotesDatabase
Sub Initialize
	mailAddress = "YOUR_ADDRESS@HERE"
	
	Dim ws As New NotesUIWorkspace
	Dim uidoc As NotesUIDocument
	Dim partno As String
	Dim db As NotesDatabase
	Dim view As NotesView
	Dim doc As NotesDocument
	Dim collection As NotesDocumentCollection
	Dim memo As NotesDocument
	Dim body As NotesRichTextItem
	Dim range As NotesRichTextRange
	Dim count As Integer
	
	Set session = New NotesSession
	Set db = session.CurrentDatabase
	Set collection = db.UnprocessedDocuments
	
	Dim FldTitles(3) As String
	FldTitles(0) = "E-mail"
	FldTitles(1) = "Subject"
	FldTitles(2) = "Date sent"
	
	Set maildoc = db.CreateDocument
	maildoc.Form = "Memo"
	maildoc.Subject = "Summary"
	maildoc.SendTo = mailAddress
	Dim ritem As NotesRichTextItem
	Set ritem=New NotesRichTextItem(maildoc,"body") 
' passing the rich text item & other relevant details
	Set ritem = CreateTable(FldTitles, collection, ritem, "Sent items", "Summary created on " + Format(Now, "YYYY-MM-DD"))
	maildoc.send(False)
End Sub
Function CreateTable(FldTitles As Variant, doccoll  As NotesDocumentCollection, rtitem As NotesRichTextItem,msgTitle As String,msgBody As String ) As NotesRichTextItem
	'http://searchdomino.techtarget.com/tip/0,289483,sid4_gci1254682_mem1,00.html
	'Takes  Documentcollection & creates tabular information on to the passed   rtitem (rich text item)
	
	Set ritem=rtitem
	Set rtnav = ritem.CreateNavigator
	Set rstyle=session.CreateRichTextStyle 
	
	'===================================================
	'heading in the body section of the mail
	rstyle.Bold=True
	rstyle.NotesColor=COLOR_RED 
	rstyle.Underline=True
	rstyle.NotesFont=FONT_COURIER
	rstyle.FontSize=12
	Call  ritem.AppendStyle(rstyle)
	ritem.AppendText(msgTitle)
	
	rstyle.Underline=False
	rstyle.NotesColor=COLOR_BLACK
	ritem.AddNewline(2)
	
	rstyle.FontSize=10
	rstyle.Bold=False
	rstyle.NotesColor=COLOR_BLACK
	Call  ritem.AppendStyle(rstyle) 
	ritem.AppendText(msgBody)
	ritem.AddNewline(1)
	
	'===================================================
	rows=doccoll.Count +1
	cols=CInt(UBound(FldTitles)) 
	
	Call ritem.AppendTable(1, cols)
	Dim rtt As NotesRichTextTable
	Call rtnav.FindFirstElement(RTELEM_TYPE_TABLE)
	Set rtt = rtNav.GetElement 
	'=================================================
	'heading of the table
	rstyle.Bold=True
	rstyle.NotesColor=COLOR_BLUE 
	rstyle.FontSize=10
	Call  ritem.AppendStyle(rstyle)
	
	For i=0 To UBound(FldTitles) - 1
		Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
		Call ritem.BeginInsert(rtnav) 
		Call ritem.AppendText(FldTitles(i))
		Call ritem.EndInsert
	Next
	
	'=================================================
	rstyle.FontSize=10
	rstyle.Bold=False
	rstyle.NotesColor=COLOR_BLACK
	Call  ritem.AppendStyle(rstyle)
	Dim count As Integer
	count = 0
	Set  doc=doccoll.GetFirstDocument
	While Not (doc Is Nothing)
		subject = doc.GetFirstItem("Subject").values(0)
		posted = doc.GetFirstItem("PostedDate").values(0)
		Set sendTo = doc.getFirstItem("SendTo")
		For i = 0 To UBound(sendTo.values)
			Call rtt.AddRow(1)
			Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)   
			Call ritem.BeginInsert(rtnav)
			ritem.appendText(sendTo.values(i))
			Call ritem.EndInsert
			Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)   
			Call ritem.BeginInsert(rtnav)
			ritem.appendText(subject)
			Call ritem.EndInsert
			Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)   
			Call ritem.BeginInsert(rtnav)
			ritem.appendText(posted)
			Call ritem.EndInsert
		Next   
		count = count + 1
		Set doc=doccoll.GetNextDocument(doc)
	Wend
	Set CreateTable=ritem
	MsgBox "E-mails summarized: " & count	
End Function

I find it helpful to save it as the "Summarize Recipients" agent and assign it to a toolbar button that runs @Command([RunAgent]; "Summarize Recipients").

Even more awesome LotusScript mail merge for Lotus Notes + Microsoft Excel

Posted: - Modified: | geek, lotus
UPDATE: May 20, 2011 – David Turner has shared his excellent improvements. Check them out!

UPDATE: May 28, 2010 – fixed errors caused by default Option Declare. Thanks to Lisa Harnett for the feedback!
UPDATE: Oct 19, 2010 – fixed Quit(). Thanks to Vance for the feedback! Also, clarified tokens.

Based on the feedback on my Lotus Notes mail merge from a Microsoft Excel spreadsheet (2009), I've refined my merge script to make it more awesome. How is it more awesome?

  • Prompts you for drafting or sending
  • Saves sent messages
  • Allows you to customize the subject
  • Uses [ ] instead of < and > for built-in tokens ([to], [cc], [subject]) for less HTML confusion in blog posts and replies
  • Displays number of sent messages and errors
  • Closes the Microsoft Excel spreadsheet afterwards

The search-and-replace tokens are defined in the first row of your Microsoft Excel spreadsheet. The script searches for them in the message body, replaces them with the appropriate values from the current row, and either saves the message as the draft or sends the message. There are a few built-in tokens for this script ([to], [cc], [subject]) – these are case-sensitive, so enter them exactly like that. All the other tokens are up to you, so you could use FOO and BAR as search-and-replace tokens if you want.

Tokens are replaced only in the message body. If you want a variable subject line, use a formula to calculate the subject in a column with the [subject] header.

As always, test your mail merges with a small list before using it for your entire list. Create an agent and call it something like “Mail merge”. Edit the agent and set the type to LotusScript. In the (Declarations) section, add

%Include "lsconst.lss"

In the “Initialize” section, put in:

Sub Initialize
	'Mail merge script by Sacha Chua (sacha@sachachua.com)

	Dim ws As NotesUIWorkspace
	Set ws = New NotesUIWorkspace
	Dim sendTypes(1) As String
	Dim sendValue As String
	Dim errorCount As Integer
	errorCount = 0
	sendTypes(0) = "Draft messages without sending"
	sendTypes(1) = "Send messages"
	sendValue = ws.Prompt(PROMPT_OKCANCELLIST, "Sending options", "What would you like to do?", "", sendTypes)
	If (sendValue = "") Then
		Exit Sub
	End If

	Dim fileName As String
	Dim strXLFilename As String
	'Prompt for the filename - should be a Microsoft Excel file with columns, where the first row of each column
	'is a token that will be used when replacing text in the body of the message
	'Special tokens: [to], [cc], [subject] set the appropriate fields
	'Make sure the first column does not have any blank cells
	fileName$ = ws.Prompt(12, "Select file", "3")
	If fileName$ = "" Then
		Exit Sub   'Cancel was pressed
	End If
	strXLFilename = fileName$
	Dim s As New NotesSession
	Dim uidoc As NotesUIDocument
	Dim partno As String
	Dim db As NotesDatabase
	Dim view As NotesView
	Dim doc As NotesDocument
	Dim collection As NotesDocumentCollection
	Dim memo As NotesDocument
	Dim body As NotesRichTextItem
	Dim newBody As NotesRichTextItem
	Dim range As NotesRichTextRange
	Dim count As Integer

	Set db = s.CurrentDatabase
	Set collection = db.UnprocessedDocuments
	Set memo = collection.getFirstDocument()

	Dim varXLFile As variant
	'Get data from the spreadsheet
	Set varXLFile = CreateObject("Excel.Application")
	varXLFile.Visible = False
	Dim varXLWorkbook As variant
	Set varXLWorkbook = Nothing
	varXLFile.Workbooks.Open strXLFilename
	Set varXLWorkbook = varXLFile.ActiveWorkbook
	Dim varXLSheet As variant
	Set varXLSheet = varXLWorkbook.ActiveSheet

	Dim lngRow As Integer
	Dim columnNo As Integer
	Dim token As String
	Dim value As string
	lngRow = 2
	Dim maildoc As NotesDocument
	While (Not (varXLSheet.Cells(lngRow, 1).Value = ""))
		'Fill in the template
		Dim subject As string
		subject = memo.Subject(0)
		Set body = memo.GetFirstItem("Body")

		'Compose message
		
		Set maildoc = New NotesDocument(db)
		Set maildoc= db.CreateDocument()
		maildoc.Form = "Memo"
		maildoc.Subject = subject
		Set newBody = maildoc.CreateRichTextItem("Body")
		Call newBody.appendRTItem(body)
		Set range = newBody.CreateRange			

		'Count the number of fields
		'Look up tokens from the column headings and replace them
		columnNo = 1
		While Not(varXLSheet.Cells(1, columnNo).Value = "")
			token = varXLSheet.Cells(1, columnNo).Value
			value = varXLSheet.Cells(lngRow, columnNo).Value
			count = range.FindAndReplace(token, value, 16)
			If (token = "[to]") Then
				maildoc.SendTo = value
			End If
			If (token = "[cc]") Then
				maildoc.CopyTo = value
			End If
			If (token = "[subject]") Then
				maildoc.Subject = value
			End If
			columnNo = columnNo + 1
		Wend
		On Error GoTo save
		If (sendValue = sendTypes(0)) Then
			Call maildoc.Save(True, False)
		Else
			maildoc.SaveMessageOnSend = True
			maildoc.PostedDate = Now()
			Call maildoc.Send(False)
			Call maildoc.Save(True, True)
		End If
		GoTo nextrow
save:
		MessageBox("Error processing " + maildoc.sendTo)
		errorCount = errorCount + 1
		Resume Next
nextrow:
		lngRow = lngRow + 1
	Wend
	If (sendValue = sendTypes(0)) Then
		MsgBox "Drafted " & (lngRow - errorCount - 2) & " message(s). Errors: " & errorCount
	Else
		MsgBox "Sent " & (lngRow - errorCount - 2) & " message(s). Errors: " & errorCount
	End If
	Call varXLFile.Quit()
End Sub

Emacs Gnus: Filter Spam

Posted: - Modified: | emacs, wickedcoolemacs

(draft for an upcoming book called Wicked Cool Emacs)

Ah, spam, the bane of our Internet lives. There is no completely
reliable way to automatically filter spam. Spam messages that slip
through the filters and perfectly legitimate messages that get
labelled spam are all part of the occupational hazards of using the
Internet.

The fastest way to filter spam is to use an external spam-filtering
program such as Spamassassin or Bogofilter, so your spam can be
filtered in the background and you don’t have to spend time in Emacs
filtering it yourself. In an ideal world, this would be done on the
mail server so that you don’t even need to download unwanted
messages. If your inbox isn’t full of ads for medicine or stocks, your
mail server is probably doing a decent job of filtering the mail for
you.

Server-based mail filtering

As spam filtering isn’t an exact science, you’ll want to find out how
you can check your spam folder for misclassified mail. If you download
your mail through POP, find out if there’s a webmail interface that
will allow you to check if any real mail has slipped into the junk
mail pile. If you’re on IMAP, your mail server might automatically
file spam messages in a different group. Here’s how to add the spam
group to your list of groups:

  1. Type M-x gnus to bring up the group buffer.
  2. Type ^ (gnus-group-enter-server-mode).
  3. Choose the nnimap: entry for your mail server and press RET (gnus-server-read-server).
  4. Find the spam or junk mail group if it exists.
  5. Type u (gnus-browse-unsubscribe-current-group) to toggle the subscription. Subscribed groups will appear in your M-x gnus screen if they contain at least one unread message.

Another alternative is to have all the mail (spam and non-spam)
delivered to your inbox, and then let Gnus be in charge of filing it
into your spam and non-spam groups. If other people manage your mail
server, ask them if you can have your mail processed by the spam
filter but still delivered to your inbox. If you’re administering your
own mail server, set up a spam filtering system such as SpamAssassin
or BogoFilter, then read the documentation of your spam filtering
system to find out how to process the mail.

Spam filtering systems typically add a header such as “X-Spam-Status”
or “X-Bogosity” to messages in order to indicate which messages are
spam or even how spammy they are. To check if your mail server tags
your messages as spam, open one of your messages in Gnus and type C-u
g (gnus-summary-show-article) to view the complete headers and
message. If you find a spam-related header such as X-Spam-Status, you
can use it to split your mail. Add the following to your ~/.gnus:

 (setq spam-use-regex-headers t) ;; (1)
 (setq spam-regex-headers-spam "^X-Spam-Status: Yes")   ;; (2)
 (require 'spam) ;; (3)
 (spam-initialize) ;; (4)

This configures spam.el to detect spam based on message
headers(1). Set spam-regex-headers-spam to a regular expression
matching the header your mail server uses to indicate spam.(2) This
configuration should be done before the spam.el library is loaded(3)
and initialized(4), because spam.el uses the spam-use-* variables to
determine which parts of the spam library to load.

In order to take advantage of this, you’ll also need to add a rule
that splits spam messages into a different group. If you haven’t set
up mail splitting yet, read qthe instructions on setting up fancy mail
splitting in “Project XXX: Organize mail into groups”. Add (:
spam-split) to either nnmail-split-fancy or nnimap-split-fancy,
depending on your configuration. For example, your ~/.gnus may look
like this:

(setq nnmail-split-fancy
'(
;; ... other split rules go here ...
(: spam-split)
;; ... other split rules go here ...
"mail.misc")) ; default mailbox

(draft for an upcoming book called Wicked Cool Emacs, more to come!)

Emacs Gnus: Organize Your Mail

| emacs, wickedcoolemacs

People handle large volumes of mail in different ways. Keeping
everything in one mailbox can quickly become unmanageable because
messages you need to read get lost among messages you don’t need to
read.

You can move mail manually by selecting them in the summary buffer and
typing B m (gnus-summary-move-article). Then type the name of the
group to which you would like to move the message. The group will be
created if it doesn’t exist.

To move multiple messages, mark them with #
(gnus-summary-mark-as-processable) and then type B m
(gnus-summary-move-article). To unmark a message, type M-#
(gnus-summary-unmark-as-processable). To unmark all messages, type M P
U (gnus-summary-unmark-all-processable).

Automatically filing mail

Moving messages by hand is tedious and time-consuming. One way to deal
with this is to set up rules that automatically file mail into
different groups (or folders, as they’re called in other mail
clients). Gnus calls this “splitting” mail, and you can split mail on
IMAP servers as well as mail downloaded from POP3 servers to your
computer.

For example, if you’re using Gnus to read mail from an IMAP server,
you can split your messages by adding this to your ~/.gnus:

 (setq nnimap-split-inbox "INBOX") ;; (1)
 (setq nnimap-split-predicate "UNDELETED") ;; (2)
 (setq nnimap-split-rule
       '(
         ("INBOX.emacs" "^Subject:.*emacs")
         ("INBOX.work" "^To:.*you@work.example.com")    
         ("INBOX.personal" "^To:.*you@personal.example.com")    
         ("INBOX.errors" "^From:.*\\(mailer.daemon\\|postmaster\\)")   
        )) 

If you use a different inbox, change the value of
nnimap-split-inbox(1). Any messages in the inbox will be split
according to nnimap-split-rule(2), which is a list where each element
is a list containing the group’s name and a regular expression
matching the header of messages that should be filed in the group. In
this example, Gnus will move mail with subjects containing the word
“emacs” to INBOX.emacs, mail directed to you@work.example.com to the
INBOX.work group, mail directed to you@personal.example.com to the
INBOX.personal group, and mail error messages to INBOX.errors. All
other messages will be stored in INBOX.

If you’re downloading your mail from a POP3 server and storing it in
nnml, add this to your ~/.gnus instead:

 (setq nnmail-split-methods
      '(
        ("mail.emacs" "^Subject:.*emacs")
        ("mail.work" "^To:.*you@work.example.com")    
        ("mail.personal" "^To:.*you@personal.example.com")    
        ("mail.errors" "^From:.*\\(mailer.daemon\\|postmaster\\)")   
       )) 

All other messages will be stored in mail.misc.

Start M-x gnus again, and your mail will be split into the different
groups.

Where are my groups?

If you don’t see your new groups in the group buffer displayed by M-x
gnus, type A A (gnus-group-list-active) to see all the groups. Go to
the group that you would like to add to the group buffer, then type u
(gnus-group-unsubscribe-current-group) to toggle its subscription. In
this example, INBOX.automated is not subscribed to, but INBOX is.

 U    13: INBOX.automated 
      76: INBOX 

When you type M-x gnus again, you’ll see your subscribed groups if
they have unread messages.

nnimap-split-rule and nnmail-split-methods allow you to filter
interesting or uninteresting mail into different groups based on their
headers. Gnus comes with an even more powerful mail splitting engine.
In fact, Gnus comes with “fancy mail splitting.”

Fancy mail splitting

With fancy mail splitting and some configuration, you can split mail
based on a combination of criteria. You can even manually file a
message and have Gnus automatically file incoming replies in the same
group.

To configure an IMAP connection to use fancy mail splitting, add the
following to your ~/.gnus:

 (setq nnimap-split-inbox "INBOX")
 (setq nnimap-split-predicate "UNDELETED")
 (setq nnmail-split-fancy ;; (1)
       '(|                                ;; (2)
         (: gnus-registry-split-fancy-with-parent) ;; (3)
         ;; splitting rules go here       ;; (4)
         "INBOX"                          ;; (5)
        ))
 (setq nnimap-split-rule 'nnmail-split-fancy)
 (setq nnmail-split-methods 'nnimap-split-fancy) ;; (6)
 (gnus-registry-initialize) ;; (7)

This configures IMAP to use the nnmail-split-fancy function to
determine the group for messages. Note that we’re setting the
nnmail-split-fancy variable here. If you want to process your IMAP
mail separately from your other mail, you can set the
nnimap-split-fancy variable instead. If so, also set nnimap-split-rule
to ‘nnimap-split-fancy. Using nnmail-split-fancy here makes the other
examples easier to understand, though.

The nnmail-split-fancy variable controls the splitting behavior(1). The
“|” symbol means that that the first matching rule is used(2). For
example, if the message being processed is a reply to a message that
Gnus knows about, then the gnus-registry-split-fancy-with-parent
function will return the name of the group, and nnmail-split-fancy
will file the message there(3). You can add other splitting rules as
well(4). If messages don’t match any of these rules, the last rule
specifies that the messages will be filed in INBOX(5). Set
nnmail-split-methods to nnimap-split-fancy as well in order to work
around some assumptions in other parts of the code(6). After that,
initialize the Gnus registry(7), which is responsible for tracking
moved and deleted messages. This allows you to automatically split
replies into the same folders as the original messages.

To configure fancy mail splitting with an nnml backend (suggested
configuration for POP3), add the following to your ~/.gnus instead:

 (gnus-registry-initialize)
 (setq nnmail-split-fancy                 
       '(|                                
         (: gnus-registry-split-fancy-with-parent)
         ;; splitting rules go here       
         "mail.misc"                          ;; (1)
        ))
 (setq nnmail-split-methods 'nnmail-split-fancy)    

This code is similar to the IMAP example, except that the default
mailbox name for nnml is mail.misc(1).

Here’s how the previous rules in nnmail-split-methods would be
translated to nnmail-split-fancy rules for an IMAP configuration:

 (setq nnmail-split-fancy
      '(|
        (: gnus-registry-split-fancy-with-parent)
         ;; splitting rules go here       
        (from mail "INBOX.errors")   ;; (1)
        (any "you@work.example.com" "INBOX.work")   ;; (2)
        (any "you@personal.example.com" "INBOX.personal") ;; 
        ("subject" "emacs" "INBOX.emacs") ;; (3)
        "INBOX"    ;; or "mail.misc" for nnml/POP3
       )) 

The from keyword matches against the “From”, “Sender”, and
“Resent-From” fields, while the mail keyword matches common mail
system addresses(1). The corresponding to keyword matches against
the “To”, “Cc”, “Apparently-To”, “Resent-To” and “Resent-Cc” headers,
while any matches the fields checked by the from and to
keywords(2). You can also compare against the subject
and other headers(3).

You can use logic in splitting rules, too. For example, if you like
reading the jokes on joke-mailing-list@example.com, but you don’t like
the ones sent by vi-guy@example.com (he not only has a bad sense of
humor, but also likes picking on Emacs!), you can use a rule like
this in your nnmail-split-fancy:

         ;; ... other splitting rules go here...
         (any "joke-mailing-list@example.com"   ;; (1)
              (| (from "vi-guy@example.com" "INBOX.junk") ;; (2)
                 "INBOX.jokes")) ;; (3)
         ;; ... other splitting rules go here

The first rule matches all messages with
“joke-mailing-list@example.com” in from- or to-related headers.
Matching messages are processed with another split rule, which moves
messages from vi-guy@example.com to a separate group(2) and files the
other messages in INBOX.jokes(3). To learn more about creating complex
rules, read the Gnus Info manual for “Fancy Mail Splitting”.

Emacs Gnus: Searching Mail

Posted: - Modified: | emacs, wickedcoolemacs

There are several ways to find messages in Emacs. From the summary
buffer, you can use / o (gnus-summary-insert-old-articles) to display
all or some old messages. You can then scan through the headers in the
summary buffer by using C-s (isearch-forward), or you can limit the
displayed messages with these commands:

Messages from a given author / a gnus-summary-limit-to-author
Messages whose subjects matching a given regular expression / / gnus-summary-limit-to-subject
Messages that match a given extra header / x gnus-summary-limit-to-extra-headers
Messages at least N days old / t gnus-summary-limit-to-age

Limits work on the messages that are currently displayed, so you can
apply multiple limits. If you make a mistake, use / w
(gnus-summary-pop-limit) to remove the previous limit. You can repeat
/ w (gnus-summary-pop-limit) until satisfied. To remove all the
limits, type C-u / w (gnus-summary-popl-limit).

If you specify a prefix, the limit’s meaning is reversed. For
example, C-u / a (gnus-summary-limit-to-author) will remove the
messages from the matching author or authors.

You can use Gnus to search the currently-displayed messages by using
M-s (gnus-summary-search-article-forward) and M-r
(gnus-summary-search-article-backward).

If you want to search a lot of mail, you’ll find NNIR handy. NNIR is a
front-end to mail search engines which can index your mail and return
search results quickly. If you want to use NNIR with a local or remote
IMAP server, you will need to use nnir.el and imap.el. If you download
your mail using fetchmail or connect to a POP3 server and use an nnml
backend, you can use NNIR with a search engine such as swish-e to
search your ~/Mail directory efficiently.

1.6.7.1 Setting up IMAP and NNIR

If you use IMAP, then your mail is stored on the mail server and
you’ll need to use the IMAP search interface to search through
it. Download nnir.el from
http://www.emacswiki.org/cgi-bin/wiki/download/nnir.el and save it to
your ~/elisp directory. You will also need an imap.el that is newer
than the one that comes with Emacs 22. Download imap.el from
http://www.emacswiki.org/cgi-bin/wiki/download/imap.el and save it to
your ~/elisp directory as well. Because Gnus comes with an older
version of imap.el, you will need to make sure that the new version of
imap.el is loaded. Add the following to your ~/.gnus:

(add-to-list 'load-path "~/elisp")
(load-file "~/elisp/imap.el")
(require 'nnir)

Restart your Emacs. You can check if the correct version of imap.el
has been loaded by typing M-x locate-library and specifying
imap.el. If Emacs reports “~/elisp/imap.el”, then Gnus is configured
to use the updated imap.el.

1.6.7.2 Setting up POP3 and NNIR

If you use the configuration for POP3 that is suggested in this
chapter, then your mail is stored in the nnml backend, which uses one
file per message. To search this using NNIR, to install nnir.el and an
external search mail engine. The Namazu search engine runs on Linux,
UNIX, and Microsoft Windows, so that’s what we’ll talk about here. To
find and configure other mail search engines supported by NNIR, check
out the comments in nnir.el.

First, you’ll need to download and install Namazu. If Namazu is
available as a package for your distribution, install it that way, as
it depends on a number of other programs. An installer for Microsoft
Windows can be found at http://www.namazu.org/windows/ . If you need
to build Namazu from source, you can get the source code and instructions
from http://www.namazu.org .

After you’ve installed Namazu, create a directory for Namazu’s index
files, such as ~/.namazu-mail. Then index your mail by typing this at
the command-line:

mknmz --mailnews -O ~/.namazu-mail ~/Mail

and add the following to your ~/.gnus:

(add-to-list 'load-path "~/elisp")
(require 'nnir)
(setq nnir-search-engine 'namazu)
(setq nnir-namazu-index-directory (expand-file-name "~/.namazu-mail"))
(setq nnir-namazu-remove-prefix (expand-file-name "~/Mail"))
(setq nnir-mail-backend gnus-select-method)
1.6.7.3 Searching your mail with NNIR

From the group buffer displayed by M-x gnus, you can type G G
(gnus-group-make-nnir-group) to search your mail for a keyword.

If you’re using the Namazu search engine, then you can use more
sophisticated search queries such as:

Linux Emacs messages that contain both “Linux” and “Emacs”
Linux or Emacs messages that contain either “Linux” or “Emacs”
Emacs not Linux messages that contain “Emacs” but not “Linux”
Emacs and (Linux or Windows) messages that contain “Emacs” and either “Linux” or “Windows”
“apple pie” messages that contain the phrase “apple pie”
{apple pie} messages that contain the phrase “apple pie”
+from:example@example.com messages with example@example.com in the From: header
+subject:”apple pie” messages with the phrase “apple pie” in the Subject: header
+subject:apple +subject:pie messages whose Subject: headers contain both “apple” and “pie”

If
matching messages are found, then you will see a temporary group with
the results. Although you can’t delete messages from this view,
reading and replying to these messages is the same as reading and
replying to regular messages.

To see a message in its original context, type G T
(gnus-summary-nnir-goto-thread) from the summary buffer. This opens
the message’s original group. If Gnus asks you how many articles to
load, press RET to accept the default of all the articles.


This is a draft for the Wicked Cool Emacs book I’m working on. =) Hope it helps!

Geek: How to use offlineimap and the dovecot mail server to read your Gmail in Emacs efficiently

Posted: - Modified: | emacs, geek
2015-12-24: Updated with config changes now that I’m back to using Gnus+dovecot+offlineimap+Gmail
2014-04-09: This post is from 2008. =) I think I used dovecot+offlineimap because Gnus and maildir weren’t getting along properly and directly connecting with IMAP to Gmail’s server was slow, but things have probably changed a fair bit since then. I eventually moved to using the Gmail web interface for most things, but I still miss my Gnus setup!
  1. Make sure you’ve set up Postfix or some other mail server that can send mail.
  2. Install dovecot (IMAP server) and offlineimap (IMAP synchronization). You can probably find binaries for your distribution.
  3. Edit /etc/dovecot/conf.d/10-mail.conf and set the following:
    mail_location = maildir:~/Maildir:LAYOUT=fs
  4. Use the instructions from http://unix.stackexchange.com/questions/44214/encrypt-offlineimap-password to set up GPG-encrypted passwords. (optional)
  5. Put the following in ~/.offlineimaprc, changing the details as needed.
    [general]
    accounts = SachaGmail
    pythonfile = ~/bin/offlineimap-password.py
    
    [Account SachaGmail]
    localrepository = Local
    remoterepository = Gmail
    status_backend = sqlite
    
    [Repository Local]
    type = Maildir
    localfolders = ~/Maildir
    
    [Repository Gmail]
    type = Gmail
    maxconnections = 2
    remoteuser = sacha@sachachua.com
    realdelete = no
    folderfilter = lambda foldername: foldername in ['INBOX', '[Gmail]/All Mail', '[Gmail]/Sent Mail', '[Gmail].Starred', '[Gmail].Drafts', '[Gmail].Important']
    nametrans = lambda folder: re.sub('^INBOX$', '[Gmail].Inbox', folder)
    sslcacertfile = /etc/ssl/certs/ca-certificates.crt
    remotepasseval = mailpasswd("gmail")
    

    If you feel comfortable specifying your password in your ~/.offlineimaprc, you can do so by changing remotepasseval to remotepass. If so, you don’t need the pythonfile line.

  6. chmod go-rwx ~/.offlineimaprc for a little bit of safety.
  7. Type offlineimap to start synchronizing.
  8. While that’s synchronizing, use something like this as your ~/.gnus:
    (setq gnus-select-method
          '(nnimap "Mail"
    	       (nnimap-address "localhost")
    	       (nnimap-stream network)
    	       (nnimap-authenticator login)))
    
    (setq user-mail-address "youremail@example.com")
    (setq gnus-ignored-from-addresses "youruser")
    
  9. Start Emacs. Start Gnus with M-x gnus. If you don’t see the INBOX group, press ^ (gnus-group-enter-server-mode), open nnimap:Mail, move your cursor to the INBOX, and either press RET to go into the group or press u (gnus-browse-unsubscribe-current-group) to toggle the subscription status until you’re subscribed to the group. Then it should show up on the group screen (M-x gnus).

Hope that helps. Have fun!