Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: Email

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

On 24 Aug 2000 04:11:27 -0400, Daniel Reeves <dreeves at eecs.umich.edu>
wrote:

>I wrote such a package for emailing myself the results of long-running
>calculations:
>
>http://ai.eecs.umich.edu/people/dreeves/misc/
>  (Mail.nb and Mail.m)
>
>It basically just does this:
>
>stream = OpenWrite["!/usr/lib/sendmail -oi -t"];
>WriteString[stream, "headers...\n\nbody..."];
>Close[stream];
>
>I imagine there's no reasonable way to do such a thing on windows.
>
>--    --    --    --    --    --    --    --    --    --    --    -- 
>Daniel Reeves               http://ai.eecs.umich.edu/people/dreeves/
>
>--- \/   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_] :=
    JavaBlock[
        Module[{props, session, msg, from, to},
            InstallJava[];
            props = JavaNew["java.util.Properties"];
            props at put[MakeJavaObject["mail.smtp.host"],
                      MakeJavaObject["smtp.enteract.com"]];
            props at put[MakeJavaObject["mail.user"],
                      MakeJavaObject["tgayley"]];
            LoadClass["javax.mail.Session"];
            session = Session`getDefaultInstance[props, Null];
            msg = JavaNew["javax.mail.internet.MimeMessage", session];
            from = JavaNew["javax.mail.internet.InternetAddress",
                           "tgayley at wolfram.com"];
            to = JavaNew["javax.mail.internet.InternetAddress", addr];
            LoadClass["javax.mail.Message$RecipientType"];
            msg at setRecipients[Message$RecipientType`TO, {to}];
            msg at setSubject[subject];
            msg at setContent[MakeJavaObject[content], "text/plain"];
            msg at setFrom[from];
            LoadClass["javax.mail.Transport"];
            Transport`send[msg]
        ]
    ]


--Todd

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