MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Email

  • To: mathgroup at
  • Subject: [mg25051] Re: [mg24927] Email
  • From: tgayley at (Todd Gayley)
  • Date: Sun, 3 Sep 2000 22:11:09 -0400 (EDT)
  • Organization: Wolfram Research, Inc.
  • References: <8o2lbf$>
  • Sender: owner-wri-mathgroup at

On 24 Aug 2000 04:11:27 -0400, Daniel Reeves <dreeves at>

>I wrote such a package for emailing myself the results of long-running
>  (Mail.nb and Mail.m)
>It basically just does this:
>stream = OpenWrite["!/usr/lib/sendmail -oi -t"];
>WriteString[stream, "headers...\n\nbody..."];
>I imagine there's no reasonable way to do such a thing on windows.
>--    --    --    --    --    --    --    --    --    --    --    -- 
>Daniel Reeves     
>--- \/   FROM Mitja Lakner AT 00.08.22 16:22 (Today)   \/ ---
>> Is it possible to send Email directly from Mathematica?
>> Any package of the form
>> Email[x at x,Text]?
>> ML

You can use J/Link to send email directly from Mathematica. Java has a
standard extension for dealing with email, called JavaMail. Once you
install it, you can use the following Mathematica program to send
mail. The program has some hardcoded strings appropriate for me;
obviously users would have to change these.

This program is essentially a line-for-line transalation of a JavaMail
sample program into J/Link's Mathematica syntax, so although it looks
complicated, it is pretty straightforward to write.

This solution is much more complex than Dan's, but it will work
unmodified on all platforms that Mathematica runs on. The real power
of J/Link is that with another short program you can _read_ email into
Mathematica. You can actually interact with a running Mathematica
program remotely, via email.

EMail[addr_, subject_, content_] :=
        Module[{props, session, msg, from, to},
            props = JavaNew["java.util.Properties"];
            props at put[MakeJavaObject[""],
            props at put[MakeJavaObject["mail.user"],
            session = Session`getDefaultInstance[props, Null];
            msg = JavaNew["javax.mail.internet.MimeMessage", session];
            from = JavaNew["javax.mail.internet.InternetAddress",
                           "tgayley at"];
            to = JavaNew["javax.mail.internet.InternetAddress", addr];
            msg at setRecipients[Message$RecipientType`TO, {to}];
            msg at setSubject[subject];
            msg at setContent[MakeJavaObject[content], "text/plain"];
            msg at setFrom[from];


Todd Gayley
Wolfram Research

  • Prev by Date: Re: plotsymbol
  • Next by Date: Re: More troubles coming from indexed variables
  • Previous by thread: discontinuous 3D plot and error messages
  • Next by thread: NotebookSave