New in Wolfram Mathematica 7: Integrated Programmatic Email  previous | next 
Generate and Send Fully Formatted Reports
Generate fully formatted reports and email as PDF attachments.
In[1]:=

Click for copyable input
$props = {"IUPACName", "CASNumber", "MolecularFormulaDisplay", 

   "MolecularWeight", "MolarVolume", "StructureDiagram"};

$propNames = {"IUPAC Name", "CAS Number", "Molecular Formula", 

   "Molecular Weight", "Molar Volume", "Structure Diagram"};

chemGrid[chem_String] := 

 Module[{data}, data = ChemicalData[chem, #] & /@ $props;

  Grid[Partition[Riffle[$propNames, data], 2], Alignment -> Right, 

   Frame -> All]

  ]
In[2]:=

Click for copyable input
nb = CreateDocument[

    CellGroup[

      {TextCell[ChemicalData[#, "Name"], "Section"],

       ExpressionCell[

        Quiet[chemGrid[#]], "Output"]},

       Open] & /@ ChemicalData["Ester"],

    WindowTitle -> "Esters"];
In[3]:=

Click for copyable input
SendMail[

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

  "Subject" -> "Ester Chemical Properties Report",

  "Body" ->

   "Hi Barb,

   

   The info you wanted about esters is attached."

  ,

  "Attachments" -> Export["Esters.pdf", nb, "PDF"]

  ];