New in Wolfram Mathematica 7: Integrated Programmatic Email  previous | next 
Programmatically Manage Email Addresses
Send a different message to each person in a list.
In[1]:=

Click for copyable input
data = {

   {"Gauss", "Jane", "Q", 2},

   {"Archimedes", "John", "Q", 3},

   {"Babbage", "Chuck", "", 5},

   {"Newton", "Jenn", "R", 1},

   {"Maxwell", "Juan", "V", 4},

   {"Boltzmann", "Manuela", "J", 7},

   {"Fibonacci", "Fred", "F", 6},

   {"Gibbs", "Rachel", "G", 9},

   {"Dewar", "John", "W", 8}

   };
In[2]:=

Click for copyable input
messageForm = "Hello `1`,\n\nYou are number `2` in the queue.";

buildEmail[messageForm_String, entry_] := (

  {"To" -> ToLowerCase@entry[[2]] <> "example@wolfram.com",

   "Subject" -> "Position in queue",

   "Body" -> StringReplace[messageForm, {"`1`" -> entry[[2]],

      "`2`" -> ToString@entry[[4]]}] 

   }

  )
In[3]:=

Click for copyable input
SendMail[buildEmail[messageForm, #]] & /@ data;