Sending Email

Sending email from the Wolfram Language.

The examples below require that the default mail account settings have been configured in the Internet Connectivity ▶ Mail Settings tab of the Preferences dialog.

This sends a basic email message:

SendMail[
<|"To"->"info@wolfram.com",
"Subject"->"Example Message",
"Body"->"My text"|>
]

This sends files as attachments:

Table[Export["sinPlot"<>ToString@n<>".jpg",Plot[Sin[x],{x,0,2n π}]],{n,3}]

SendMail[
<|"To"->"info@wolfram.com",
"Subject"->"Example Attachments",
"Body"->"Files are attached.",
"Attachments"->{"sinPlot1.jpg","sinPlot2.jpg","sinPlot3.jpg"}|>
]

You can also send arbitrary Wolfram Language expressions within the body of the email. (RefLink[SendMail, paclet:ref/SendMail]) automatically converts the expressions to an appropriate file format and attaches them (inline, where possible) to the email.

This converts Wolfram Language expressions in the body of the email and attaches them appropriately for email:

SendMail[
<|"To"->"info@wolfram.com",
"Subject"->"Sending Mathematica Expressions as Attachments",
"Body"->{"Attach arbitrary Mathematica expressions to the body of your email.\nE.g., images:\n",,
"Mathematica graphics: \n",,
"Sounds: \n",Sound[Play[Sin[4Pi t]^2Sin[440 2Pi t],{t,0,1}]],
"Notebooks: \n",CreateDocument[{x+y,1/x+1/y}]}|>
]