#!/bin/bash

# Second value (email address) is only used for sorting
TO=`cat | sort -t$'\t' -k2 -u | cut -f1 | tr "\n" ","`
TO=${TO//\\/\\\\} # Escape the use of \
TO=${TO//\'/\\\'} # Escape the use of '

cat << END
{ actions = ( {
			type = createMessage;
			headers = {
				"to" = '${TO}';
			};
			resultActions = ( { type = openMessage; } );
		},
	);
}
END
