haiku/docs/user/mail/Mass Mailing Tips/MailToTemplate
Alexander G.M. Smith c181c43dc1 More documentation moved over from SourceForge, so it's not quite up to date.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15965 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-15 22:43:21 +00:00

19 lines
722 B
Bash

#!/bin/sh
# Make a mail merge letter by combining data from a given people file and a
# template letter text file.
# $Revision: 1.1 $
# Some code from Scot Hacker's PeoplePorter http://www.bebits.com/app/1747
PeopleFile=$1
echo "Mail merging using people file: $PeopleFile"
Name=$(catattr META:name "$PeopleFile" | sed s/\ \:\ /%/g | cut -f3 -d\%)
EMail=$(catattr META:email "$PeopleFile" | sed s/\ \:\ /%/g | cut -f3 -d\%)
Company=$(catattr META:company "$PeopleFile" | sed s/\ \:\ /%/g | cut -f3 -d\%)
sed "s/NAME/$Name/g" <TemplateLetter.txt >/tmp/stage1
sed "s/EMAIL/$EMail/g" </tmp/stage1 >/tmp/stage2
sed "s/COMPANY/$Company/g" </tmp/stage2 >/tmp/stage3
mail -v -s "Test Message to $Name" "$EMail" </tmp/stage3