New in Wolfram Mathematica 7: Integrated Programmatic Email  previous | next 
Send Programmatically Generated Spreadsheets
Use CountryData and SendMail to programmatically generate and email an Excel spreadsheet of country properties.
In[1]:=

Click for copyable input
$countries = CountryData["Countries"];

$props = {"Area", "CapitalCity", "GDP", "Name", "Population", 

   "CallingCode", "CountryCode", "FullName", "FullNativeName", 

   "InternetCode", "ISOName", "Name", "NationalityName", "NativeName",

    "UNCode", "UNNumber"};

$colLabels = Prepend[$props, "Country"];

countryProps[country_String] := CountryData[country, #] & /@ $props

data = Prepend[

   Prepend[countryProps[#], #] & /@ $countries, $colLabels];

data[[2 ;;, 3]] = 

  StringDrop[StringDrop[ToString[#], -1], 1] & /@ data[[2 ;;, 3]];
In[2]:=

Click for copyable input
SendMail[

  "To" -> "jackexample@wolfram.com",

  "Subject" -> "Country Data Spreadsheet",

  "Body" -> "Hi Jack,

   

   The Excel spreadsheet is attached.",

  "Attachments" -> Export["countryData.xls", data, "XLS"]

  ];
Out[2]=