Sending e-mails from a NetRexx application.

classic Classic list List threaded Threaded
26 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Sending e-mails from a NetRexx application.

ThSITC
Hello there,
    for a customer application I'm currently writing I would need your help:

How can I *send* a series of e-mails  from a NetRexx application to a
list of e-mail adresses?

There are for sure Java classes to do that, but I cannot find those in
my books.

When anybody of you does have a sample of NetRexx (or Java) code
how to do that, please forward this sample to me!

Thanks in advance,
Thomas Schneider.

Thomas Schneider (www.thsitc.com)
_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Thomas Schneider, Vienna, Austria (Europe) :-)

www.thsitc.com
www.db-123.com
Reply | Threaded
Open this post in threaded view
|

Re: Sending e-mails from a NetRexx application.

David Requena
Thomas,

Have a look at http://www.oracle.com/technetwork/java/javamail/index-138643.html

Javamail is an optional component for Java SE, so you need to download it separately. Lots of samples at the docs.

HTH

-
Saludos / Kind regards,
David Requena

NOTE: The opinions expressed here represent the opinions
of the authors and do not necessarily represent the opinions
of those who hold other opinions.


-----Original Message-----
From: Thomas Schneider <[hidden email]>
Sender: [hidden email]
Date: Sat, 21 May 2011 12:36:09
To: IBM Netrexx<[hidden email]>
Reply-To: [hidden email],
        IBM Netrexx <[hidden email]>
Subject: [Ibm-netrexx] Sending e-mails from a NetRexx application.

Hello there,
    for a customer application I'm currently writing I would need your help:

How can I *send* a series of e-mails  from a NetRexx application to a
list of e-mail adresses?

There are for sure Java classes to do that, but I cannot find those in
my books.

When anybody of you does have a sample of NetRexx (or Java) code
how to do that, please forward this sample to me!

Thanks in advance,
Thomas Schneider.

Thomas Schneider (www.thsitc.com)
_______________________________________________
Ibm-netrexx mailing list
[hidden email]


_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Sending e-mails from a NetRexx application.

Robert L Hamilton
In reply to this post by ThSITC
Tom; Get a copy of BLATT,  a command line program which can be run from Rexx and perhaps from NetRexx.  I think BLATT has been run from JAVA.

Bob Hamilton
Richardson Texas USA

On Sat, May 21, 2011 at 5:36 AM, Thomas Schneider <[hidden email]> wrote:
Hello there,
  for a customer application I'm currently writing I would need your help:

How can I *send* a series of e-mails  from a NetRexx application to a list of e-mail adresses?

There are for sure Java classes to do that, but I cannot find those in my books.

When anybody of you does have a sample of NetRexx (or Java) code
how to do that, please forward this sample to me!

Thanks in advance,
Thomas Schneider.

Thomas Schneider (www.thsitc.com)
_______________________________________________
Ibm-netrexx mailing list
[hidden email]



_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Sending e-mails from a NetRexx application.

alansam
JavaMail is the way to go, here's a link: http://www.oracle.com/technetwork/java/javamail/index.html.  Using the JavaMail API keeps your code "pure Java" and therefore "pure NetRexx" and doesn't pollute your application with external dependencies that may introduce licensing issues.

I've written several email based applications in Java using the JavaMail API for my employer so I can attest that the API is pretty easy to get on with (at least from a Java standpoint).  I'm certain it will be just as easy from NetRexx, just a SMOP.

Alan.


On 21 May 2011 05:19, Robert Hamilton <[hidden email]> wrote:
Tom; Get a copy of BLATT,  a command line program which can be run from Rexx and perhaps from NetRexx.  I think BLATT has been run from JAVA.

Bob Hamilton
Richardson Texas USA


On Sat, May 21, 2011 at 5:36 AM, Thomas Schneider <[hidden email]> wrote:
Hello there,
  for a customer application I'm currently writing I would need your help:

How can I *send* a series of e-mails  from a NetRexx application to a list of e-mail adresses?

There are for sure Java classes to do that, but I cannot find those in my books.

When anybody of you does have a sample of NetRexx (or Java) code
how to do that, please forward this sample to me!

Thanks in advance,
Thomas Schneider.

Thomas Schneider (www.thsitc.com)
_______________________________________________
Ibm-netrexx mailing list
[hidden email]



_______________________________________________
Ibm-netrexx mailing list
[hidden email]





--
Can't tweet, won't tweet!

_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Alan

--
Needs more cowbell.
Reply | Threaded
Open this post in threaded view
|

Re: Sending e-mails from a NetRexx application.

ThSITC
Hello Alan & all,
   1.) Thanks to all who gave hints which way to go.
   2.) It looks, as a first glance, that JvaMail is exactly what I was searching for.
I'l have, however, have to learn again a lot after downloading the distribution.

Hence again one question, when allowed:

Does nyone of you have a resonable small NetRexx sample to SEND mails using JavaMail (written preferably in NetRexx) ?

Thomas.
======================================================
Am 21.05.2011 20:42, schrieb Alan Sampson:
JavaMail is the way to go, here's a link: http://www.oracle.com/technetwork/java/javamail/index.html.  Using the JavaMail API keeps your code "pure Java" and therefore "pure NetRexx" and doesn't pollute your application with external dependencies that may introduce licensing issues.

I've written several email based applications in Java using the JavaMail API for my employer so I can attest that the API is pretty easy to get on with (at least from a Java standpoint).  I'm certain it will be just as easy from NetRexx, just a SMOP.

Alan.


On 21 May 2011 05:19, Robert Hamilton <[hidden email]> wrote:
Tom; Get a copy of BLATT,  a command line program which can be run from Rexx and perhaps from NetRexx.  I think BLATT has been run from JAVA.

Bob Hamilton
Richardson Texas USA


On Sat, May 21, 2011 at 5:36 AM, Thomas Schneider <[hidden email]> wrote:
Hello there,
  for a customer application I'm currently writing I would need your help:

How can I *send* a series of e-mails  from a NetRexx application to a list of e-mail adresses?

There are for sure Java classes to do that, but I cannot find those in my books.

When anybody of you does have a sample of NetRexx (or Java) code
how to do that, please forward this sample to me!

Thanks in advance,
Thomas Schneider.

Thomas Schneider (www.thsitc.com)
_______________________________________________
Ibm-netrexx mailing list
[hidden email]



_______________________________________________
Ibm-netrexx mailing list
[hidden email]





--
Can't tweet, won't tweet!
_______________________________________________ Ibm-netrexx mailing list [hidden email]


--
Thomas Schneider (www.thsitc.com)

_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Thomas Schneider, Vienna, Austria (Europe) :-)

www.thsitc.com
www.db-123.com
Reply | Threaded
Open this post in threaded view
|

Re: Sending e-mails from a NetRexx application.

Robert L Hamilton
I would also the thankful for a Leg Up on JavaMail/NetRexx

BobH

On Sun, May 22, 2011 at 11:23 AM, Thomas Schneider <[hidden email]> wrote:
Hello Alan & all,
   1.) Thanks to all who gave hints which way to go.
   2.) It looks, as a first glance, that JvaMail is exactly what I was searching for.
I'l have, however, have to learn again a lot after downloading the distribution.

Hence again one question, when allowed:

Does nyone of you have a resonable small NetRexx sample to SEND mails using JavaMail (written preferably in NetRexx) ?

Thomas.
======================================================
Am <a href="tel:21.05.2011%2020" value="+12105201120" target="_blank">21.05.2011 20:42, schrieb Alan Sampson:
JavaMail is the way to go, here's a link: http://www.oracle.com/technetwork/java/javamail/index.html.  Using the JavaMail API keeps your code "pure Java" and therefore "pure NetRexx" and doesn't pollute your application with external dependencies that may introduce licensing issues.

I've written several email based applications in Java using the JavaMail API for my employer so I can attest that the API is pretty easy to get on with (at least from a Java standpoint).  I'm certain it will be just as easy from NetRexx, just a SMOP.

Alan.


On 21 May 2011 05:19, Robert Hamilton <[hidden email]> wrote:
Tom; Get a copy of BLATT,  a command line program which can be run from Rexx and perhaps from NetRexx.  I think BLATT has been run from JAVA.

Bob Hamilton
Richardson Texas USA


On Sat, May 21, 2011 at 5:36 AM, Thomas Schneider <[hidden email]> wrote:
Hello there,
  for a customer application I'm currently writing I would need your help:

How can I *send* a series of e-mails  from a NetRexx application to a list of e-mail adresses?

There are for sure Java classes to do that, but I cannot find those in my books.

When anybody of you does have a sample of NetRexx (or Java) code
how to do that, please forward this sample to me!

Thanks in advance,
Thomas Schneider.

Thomas Schneider (www.thsitc.com)
_______________________________________________
Ibm-netrexx mailing list
[hidden email]



_______________________________________________
Ibm-netrexx mailing list
[hidden email]





--
Can't tweet, won't tweet!
_______________________________________________ Ibm-netrexx mailing list [hidden email]


--
Thomas Schneider (www.thsitc.com)

_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Sending e-mails from a NetRexx application.

David Requena
OK, here you go.

This is the simplest example I could come with (actualy a ported java example). Just text email, no attachments, mime/multipart, cryptography or anything fancy, which you can do with javamail.

You need mail.jar from Javamail on your classpath for this to compile and run.


import java.util.
import javax.mail.
import javax.mail.internet.
import javax.activation.

class MailSender public

  method main(args=String[]) public static

    -- set these according to your needs
    mailServer    = "smtp.yourisp.net"
    mailFrom      = "[hidden email]"
    mailRecipient = "[hidden email]"
    -- an array, we could have several recipients
    mailTo = [InternetAddress(mailRecipient)]
    mailSubject = "Test E-Mail through NetRexx & Javamail"
    mailBody    = "This is a test of sending a" -
                  "plain text e-mail through NetRexx & Javamail.\n" || -
                  "Here is line 2."
                   
    sendEmail(mailTo, mailFrom, mailServer, mailSubject, mailBody)
        
        
  method sendEmail(mailTo=InternetAddress[], mailFrom, mailServer, mailSubject, mailBody) public static
        
    props = Properties()
    props.put("mail.smtp.host", String mailServer)
    -- log full exchange. this is quite verbose!!
    props.put("mail.debug", String "true")

    do

      msg = MimeMessage(Session.getInstance(props))
       
      msg.setFrom(InternetAddress(mailFrom))
      address = mailTo
      msg.setRecipients(Message.RecipientType.TO, address)
      msg.setSubject(mailSubject)
      msg.setSentDate(Date())
      msg.setText(mailBody)

      Transport.send(msg)

    catch mex=MessagingException
      mex.printStackTrace()
    end




2011/5/23 Robert Hamilton <[hidden email]>
I would also the thankful for a Leg Up on JavaMail/NetRexx

BobH


On Sun, May 22, 2011 at 11:23 AM, Thomas Schneider <[hidden email]> wrote:
Hello Alan & all,
   1.) Thanks to all who gave hints which way to go.
   2.) It looks, as a first glance, that JvaMail is exactly what I was searching for.
I'l have, however, have to learn again a lot after downloading the distribution.

Hence again one question, when allowed:

Does nyone of you have a resonable small NetRexx sample to SEND mails using JavaMail (written preferably in NetRexx) ?

Thomas.
======================================================
Am <a href="tel:21.05.2011%2020" value="+12105201120" target="_blank">21.05.2011 20:42, schrieb Alan Sampson:
JavaMail is the way to go, here's a link: http://www.oracle.com/technetwork/java/javamail/index.html.  Using the JavaMail API keeps your code "pure Java" and therefore "pure NetRexx" and doesn't pollute your application with external dependencies that may introduce licensing issues.

I've written several email based applications in Java using the JavaMail API for my employer so I can attest that the API is pretty easy to get on with (at least from a Java standpoint).  I'm certain it will be just as easy from NetRexx, just a SMOP.

Alan.


On 21 May 2011 05:19, Robert Hamilton <[hidden email]> wrote:
Tom; Get a copy of BLATT,  a command line program which can be run from Rexx and perhaps from NetRexx.  I think BLATT has been run from JAVA.

Bob Hamilton
Richardson Texas USA


On Sat, May 21, 2011 at 5:36 AM, Thomas Schneider <[hidden email]> wrote:
Hello there,
  for a customer application I'm currently writing I would need your help:

How can I *send* a series of e-mails  from a NetRexx application to a list of e-mail adresses?

There are for sure Java classes to do that, but I cannot find those in my books.

When anybody of you does have a sample of NetRexx (or Java) code
how to do that, please forward this sample to me!

Thanks in advance,
Thomas Schneider.

Thomas Schneider (www.thsitc.com)
_______________________________________________
Ibm-netrexx mailing list
[hidden email]



_______________________________________________
Ibm-netrexx mailing list
[hidden email]





--
Can't tweet, won't tweet!
_______________________________________________ Ibm-netrexx mailing list [hidden email]


--
Thomas Schneider (www.thsitc.com)

_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]





--
Saludos / Regards,
David Requena


_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Sending e-mails from a NetRexx application.

ThSITC
Hello David,
   I have been off the Internet for 2 weeks. Many thanks for your clear example!
Thomas.
====================================================
Am 23.05.2011 17:32, schrieb David Requena:
OK, here you go.

This is the simplest example I could come with (actualy a ported java example). Just text email, no attachments, mime/multipart, cryptography or anything fancy, which you can do with javamail.

You need mail.jar from Javamail on your classpath for this to compile and run.


import java.util.
import javax.mail.
import javax.mail.internet.
import javax.activation.

class MailSender public

  method main(args=String[]) public static

    -- set these according to your needs
    mailServer    = "smtp.yourisp.net"
    mailFrom      = "[hidden email]"
    mailRecipient = "[hidden email]"
    -- an array, we could have several recipients
    mailTo = [InternetAddress(mailRecipient)]
    mailSubject = "Test E-Mail through NetRexx & Javamail"
    mailBody    = "This is a test of sending a" -
                  "plain text e-mail through NetRexx & Javamail.\n" || -
                  "Here is line 2."
                   
    sendEmail(mailTo, mailFrom, mailServer, mailSubject, mailBody)
        
        
  method sendEmail(mailTo=InternetAddress[], mailFrom, mailServer, mailSubject, mailBody) public static
        
    props = Properties()
    props.put("mail.smtp.host", String mailServer)
    -- log full exchange. this is quite verbose!!
    props.put("mail.debug", String "true")

    do

      msg = MimeMessage(Session.getInstance(props))
       
      msg.setFrom(InternetAddress(mailFrom))
      address = mailTo
      msg.setRecipients(Message.RecipientType.TO, address)
      msg.setSubject(mailSubject)
      msg.setSentDate(Date())
      msg.setText(mailBody)

      Transport.send(msg)

    catch mex=MessagingException
      mex.printStackTrace()
    end




2011/5/23 Robert Hamilton <[hidden email]>
I would also the thankful for a Leg Up on JavaMail/NetRexx

BobH


On Sun, May 22, 2011 at 11:23 AM, Thomas Schneider <[hidden email]> wrote:
Hello Alan & all,
   1.) Thanks to all who gave hints which way to go.
   2.) It looks, as a first glance, that JvaMail is exactly what I was searching for.
I'l have, however, have to learn again a lot after downloading the distribution.

Hence again one question, when allowed:

Does nyone of you have a resonable small NetRexx sample to SEND mails using JavaMail (written preferably in NetRexx) ?

Thomas.
======================================================
Am <a moz-do-not-send="true" href="tel:21.05.2011%2020" value="+12105201120" target="_blank">21.05.2011 20:42, schrieb Alan Sampson:
JavaMail is the way to go, here's a link: http://www.oracle.com/technetwork/java/javamail/index.html.  Using the JavaMail API keeps your code "pure Java" and therefore "pure NetRexx" and doesn't pollute your application with external dependencies that may introduce licensing issues.

I've written several email based applications in Java using the JavaMail API for my employer so I can attest that the API is pretty easy to get on with (at least from a Java standpoint).  I'm certain it will be just as easy from NetRexx, just a SMOP.

Alan.


On 21 May 2011 05:19, Robert Hamilton <[hidden email]> wrote:
Tom; Get a copy of BLATT,  a command line program which can be run from Rexx and perhaps from NetRexx.  I think BLATT has been run from JAVA.

Bob Hamilton
Richardson Texas USA


On Sat, May 21, 2011 at 5:36 AM, Thomas Schneider <[hidden email]> wrote:
Hello there,
  for a customer application I'm currently writing I would need your help:

How can I *send* a series of e-mails  from a NetRexx application to a list of e-mail adresses?

There are for sure Java classes to do that, but I cannot find those in my books.

When anybody of you does have a sample of NetRexx (or Java) code
how to do that, please forward this sample to me!

Thanks in advance,
Thomas Schneider.

Thomas Schneider (www.thsitc.com)
_______________________________________________
Ibm-netrexx mailing list
[hidden email]



_______________________________________________
Ibm-netrexx mailing list
[hidden email]





--
Can't tweet, won't tweet!
_______________________________________________ Ibm-netrexx mailing list [hidden email]


--
Thomas Schneider (www.thsitc.com)

_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]





--
Saludos / Regards,
David Requena

_______________________________________________ Ibm-netrexx mailing list [hidden email]


--
Thomas Schneider (www.thsitc.com)

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Thomas Schneider, Vienna, Austria (Europe) :-)

www.thsitc.com
www.db-123.com
Reply | Threaded
Open this post in threaded view
|

Re: Sending e-mails from a NetRexx application.

Fernando Cassia-2
In reply to this post by David Requena
On Mon, May 23, 2011 at 12:32, David Requena <[hidden email]> wrote:
>
> This is the simplest example I could come with (actualy a ported java
> example). Just text email, no attachments, mime/multipart, cryptography or
> anything fancy, which you can do with javamail.

Many thanks. However, how do you specify the smpt user name and
password? additinal parameters to Javamail?. And SSL and port number?

(I know, I should look up the javamail docs, but if you answer on this
thread it´ll be properly indexed and easier to find in the future ;)

TIA
FC

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Sending e-mails from a NetRexx application.

Fernando Cassia-2
In reply to this post by David Requena
On Mon, May 23, 2011 at 12:32, David Requena <[hidden email]> wrote:
>
> You need mail.jar from Javamail on your classpath for this to compile and
> run.

The good news is that Sun made Javamail open source back in early 2009.

And that JavaMail .jar can be downloaded directly from the maven2 repository.

http://download.java.net/maven/2/com/sun/mail/javax.mail/1.4.4/javax.mail-1.4.4.jar

The third good news is that Oracle updated JavaMail to v1.4.4 in late
January 2011. Includes NTML support.

FC
_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Sending e-mails from a NetRexx application.

Robert L Hamilton
In reply to this post by David Requena
This does not compile in jEdit/NetRexxDE.
 
BobH

On Mon, May 23, 2011 at 10:32 AM, David Requena <[hidden email]> wrote:
OK, here you go.

This is the simplest example I could come with (actualy a ported java example). Just text email, no attachments, mime/multipart, cryptography or anything fancy, which you can do with javamail.

You need mail.jar from Javamail on your classpath for this to compile and run.


import java.util.
import javax.mail.
import javax.mail.internet.
import javax.activation.

class MailSender public

  method main(args=String[]) public static

    -- set these according to your needs
    mailServer    = "smtp.yourisp.net"
    mailFrom      = "[hidden email]"
    mailRecipient = "[hidden email]"
    -- an array, we could have several recipients
    mailTo = [InternetAddress(mailRecipient)]
    mailSubject = "Test E-Mail through NetRexx & Javamail"
    mailBody    = "This is a test of sending a" -
                  "plain text e-mail through NetRexx & Javamail.\n" || -
                  "Here is line 2."
                   
    sendEmail(mailTo, mailFrom, mailServer, mailSubject, mailBody)
        
        
  method sendEmail(mailTo=InternetAddress[], mailFrom, mailServer, mailSubject, mailBody) public static
        
    props = Properties()
    props.put("mail.smtp.host", String mailServer)
    -- log full exchange. this is quite verbose!!
    props.put("mail.debug", String "true")

    do

      msg = MimeMessage(Session.getInstance(props))
       
      msg.setFrom(InternetAddress(mailFrom))
      address = mailTo
      msg.setRecipients(Message.RecipientType.TO, address)
      msg.setSubject(mailSubject)
      msg.setSentDate(Date())
      msg.setText(mailBody)

      Transport.send(msg)

    catch mex=MessagingException
      mex.printStackTrace()
    end




2011/5/23 Robert Hamilton <[hidden email]>
I would also the thankful for a Leg Up on JavaMail/NetRexx

BobH


On Sun, May 22, 2011 at 11:23 AM, Thomas Schneider <[hidden email]> wrote:
Hello Alan & all,
   1.) Thanks to all who gave hints which way to go.
   2.) It looks, as a first glance, that JvaMail is exactly what I was searching for.
I'l have, however, have to learn again a lot after downloading the distribution.

Hence again one question, when allowed:

Does nyone of you have a resonable small NetRexx sample to SEND mails using JavaMail (written preferably in NetRexx) ?

Thomas.
======================================================
Am <a href="tel:21.05.2011%2020" target="_blank" value="+12105201120">21.05.2011 20:42, schrieb Alan Sampson:
JavaMail is the way to go, here's a link: http://www.oracle.com/technetwork/java/javamail/index.html.  Using the JavaMail API keeps your code "pure Java" and therefore "pure NetRexx" and doesn't pollute your application with external dependencies that may introduce licensing issues.

I've written several email based applications in Java using the JavaMail API for my employer so I can attest that the API is pretty easy to get on with (at least from a Java standpoint).  I'm certain it will be just as easy from NetRexx, just a SMOP.

Alan.


On 21 May 2011 05:19, Robert Hamilton <[hidden email]> wrote:
Tom; Get a copy of BLATT,  a command line program which can be run from Rexx and perhaps from NetRexx.  I think BLATT has been run from JAVA.

Bob Hamilton
Richardson Texas USA


On Sat, May 21, 2011 at 5:36 AM, Thomas Schneider <[hidden email]> wrote:
Hello there,
  for a customer application I'm currently writing I would need your help:

How can I *send* a series of e-mails  from a NetRexx application to a list of e-mail adresses?

There are for sure Java classes to do that, but I cannot find those in my books.

When anybody of you does have a sample of NetRexx (or Java) code
how to do that, please forward this sample to me!

Thanks in advance,
Thomas Schneider.

Thomas Schneider (www.thsitc.com)
_______________________________________________
Ibm-netrexx mailing list
[hidden email]



_______________________________________________
Ibm-netrexx mailing list
[hidden email]





--
Can't tweet, won't tweet!
_______________________________________________ Ibm-netrexx mailing list [hidden email]


--
Thomas Schneider (www.thsitc.com)

_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]





--
Saludos / Regards,
David Requena


_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Sending e-mails from a NetRexx application.

measel
In reply to this post by ThSITC
Error message ?


From: [hidden email] <[hidden email]>
To: IBM Netrexx <[hidden email]>
Sent: Mon Jun 06 12:15:07 2011
Subject: Re: [Ibm-netrexx] Sending e-mails from a NetRexx application.

This does not compile in jEdit/NetRexxDE.
 
BobH

On Mon, May 23, 2011 at 10:32 AM, David Requena <[hidden email]> wrote:
OK, here you go.

This is the simplest example I could come with (actualy a ported java example). Just text email, no attachments, mime/multipart, cryptography or anything fancy, which you can do with javamail.

You need mail.jar from Javamail on your classpath for this to compile and run.


import java.util.
import javax.mail.
import javax.mail.internet.
import javax.activation.

class MailSender public

  method main(args=String[]) public static

    -- set these according to your needs
    mailServer    = "smtp.yourisp.net"
    mailFrom      = "[hidden email]"
    mailRecipient = "[hidden email]"
    -- an array, we could have several recipients
    mailTo = [InternetAddress(mailRecipient)]
    mailSubject = "Test E-Mail through NetRexx & Javamail"
    mailBody    = "This is a test of sending a" -
                  "plain text e-mail through NetRexx & Javamail.\n" || -
                  "Here is line 2."
                   
    sendEmail(mailTo, mailFrom, mailServer, mailSubject, mailBody)
        
        
  method sendEmail(mailTo=InternetAddress[], mailFrom, mailServer, mailSubject, mailBody) public static
        
    props = Properties()
    props.put("mail.smtp.host", String mailServer)
    -- log full exchange. this is quite verbose!!
    props.put("mail.debug", String "true")

    do

      msg = MimeMessage(Session.getInstance(props))
       
      msg.setFrom(InternetAddress(mailFrom))
      address = mailTo
      msg.setRecipients(Message.RecipientType.TO, address)
      msg.setSubject(mailSubject)
      msg.setSentDate(Date())
      msg.setText(mailBody)

      Transport.send(msg)

    catch mex=MessagingException
      mex.printStackTrace()
    end




2011/5/23 Robert Hamilton <[hidden email]>
I would also the thankful for a Leg Up on JavaMail/NetRexx

BobH


On Sun, May 22, 2011 at 11:23 AM, Thomas Schneider <[hidden email]> wrote:
Hello Alan & all,
   1.) Thanks to all who gave hints which way to go.
   2.) It looks, as a first glance, that JvaMail is exactly what I was searching for.
I'l have, however, have to learn again a lot after downloading the distribution.

Hence again one question, when allowed:

Does nyone of you have a resonable small NetRexx sample to SEND mails using JavaMail (written preferably in NetRexx) ?

Thomas.
======================================================
Am <a href="tel:21.05.2011%2020" target="_blank" value="+12105201120">21.05.2011 20:42, schrieb Alan Sampson:
JavaMail is the way to go, here's a link: http://www.oracle.com/technetwork/java/javamail/index.html.  Using the JavaMail API keeps your code "pure Java" and therefore "pure NetRexx" and doesn't pollute your application with external dependencies that may introduce licensing issues.

I've written several email based applications in Java using the JavaMail API for my employer so I can attest that the API is pretty easy to get on with (at least from a Java standpoint).  I'm certain it will be just as easy from NetRexx, just a SMOP.

Alan.


On 21 May 2011 05:19, Robert Hamilton <[hidden email]> wrote:
Tom; Get a copy of BLATT,  a command line program which can be run from Rexx and perhaps from NetRexx.  I think BLATT has been run from JAVA.

Bob Hamilton
Richardson Texas USA


On Sat, May 21, 2011 at 5:36 AM, Thomas Schneider <[hidden email]> wrote:
Hello there,
  for a customer application I'm currently writing I would need your help:

How can I *send* a series of e-mails  from a NetRexx application to a list of e-mail adresses?

There are for sure Java classes to do that, but I cannot find those in my books.

When anybody of you does have a sample of NetRexx (or Java) code
how to do that, please forward this sample to me!

Thanks in advance,
Thomas Schneider.

Thomas Schneider (www.thsitc.com)
_______________________________________________
Ibm-netrexx mailing list
[hidden email]



_______________________________________________
Ibm-netrexx mailing list
[hidden email]





--
Can't tweet, won't tweet!
_______________________________________________ Ibm-netrexx mailing list [hidden email]


--
Thomas Schneider (www.thsitc.com)

_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]





--
Saludos / Regards,
David Requena


_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Sending e-mails from a NetRexx application.

Robert L Hamilton
NetRexx portable processor, version 2.05
Copyright (c) IBM Corporation, 2005.  All rights reserved.
Program MailSender.nrx
[E:\MISC\MailSender.nrx 29 42 13] Error: Unknown variable
Compilation of 'MailSender.nrx' failed [one error]
 
 
--3456789012345678901234567890123456789012345678901234567890
method sendEmail(mailTo=InternetAddress[(mailRecipient)], mailFrom, || -
   mailServer, || -
   mailSubject, mailBody) public static
 
Caracter 42 is the 'm' in 'mail'
 
Thanks for your time and enjoy the day
 
BobH
Richardson Texas USA

 
import java.util.
import javax.mail.
import javax.mail.internet.
import javax.activation.

class MailSender public

  method main(args=String[]) public static

    -- set these according to your needs
    mailServer    = "smtp.yourisp.net"
    mailFrom      = "[hidden email]"
    mailRecipient = "[hidden email]"
    -- an array, we could have several recipients
    mailTo = [InternetAddress(mailRecipient)]
    mailSubject = "Test E-Mail through NetRexx & Javamail"
    mailBody    = "This is a test of sending a" -
                  "plain text e-mail through NetRexx & Javamail.\n" || -
                  "Here is line 2."
                   
    sendEmail(mailTo, mailFrom, mailServer, mailSubject, mailBody)
        
        
  method sendEmail(mailTo=InternetAddress[], mailFrom, mailServer, mailSubject, mailBody) public static
        
    props = Properties()
    props.put("mail.smtp.host", String mailServer)
    -- log full exchange. this is quite verbose!!
    props.put("mail.debug", String "true")

    do

      msg = MimeMessage(Session.getInstance(props))
       
      msg.setFrom(InternetAddress(mailFrom))
      address = mailTo
      msg.setRecipients(Message.RecipientType.TO, address)
      msg.setSubject(mailSubject)
      msg.setSentDate(Date())
      msg.setText(mailBody)

      Transport.send(msg)

    catch mex=MessagingException
      mex.printStackTrace()
    end




2011/5/23 Robert Hamilton <[hidden email]>
I would also the thankful for a Leg Up on JavaMail/NetRexx

BobH


On Sun, May 22, 2011 at 11:23 AM, Thomas Schneider <[hidden email]> wrote:
Hello Alan & all,
   1.) Thanks to all who gave hints which way to go.
   2.) It looks, as a first glance, that JvaMail is exactly what I was searching for.
I'l have, however, have to learn again a lot after downloading the distribution.

Hence again one question, when allowed:

Does nyone of you have a resonable small NetRexx sample to SEND mails using JavaMail (written preferably in NetRexx) ?

Thomas.
======================================================
Am <a href="tel:21.05.2011%2020" target="_blank" value="+12105201120">21.05.2011 20:42, schrieb Alan Sampson:
JavaMail is the way to go, here's a link: http://www.oracle.com/technetwork/java/javamail/index.html.  Using the JavaMail API keeps your code "pure Java" and therefore "pure NetRexx" and doesn't pollute your application with external dependencies that may introduce licensing issues.

I've written several email based applications in Java using the JavaMail API for my employer so I can attest that the API is pretty easy to get on with (at least from a Java standpoint).  I'm certain it will be just as easy from NetRexx, just a SMOP.

Alan.


On 21 May 2011 05:19, Robert Hamilton <[hidden email]> wrote:
Tom; Get a copy of BLATT,  a command line program which can be run from Rexx and perhaps from NetRexx.  I think BLATT has been run from JAVA.

Bob Hamilton
Richardson Texas USA


On Sat, May 21, 2011 at 5:36 AM, Thomas Schneider <[hidden email]> wrote:
Hello there,
  for a customer application I'm currently writing I would need your help:

How can I *send* a series of e-mails  from a NetRexx application to a list of e-mail adresses?

There are for sure Java classes to do that, but I cannot find those in my books.

When anybody of you does have a sample of NetRexx (or Java) code
how to do that, please forward this sample to me!

Thanks in advance,
Thomas Schneider.

Thomas Schneider (www.thsitc.com)
_______________________________________________
Ibm-netrexx mailing list
[hidden email]



_______________________________________________
Ibm-netrexx mailing list
[hidden email]





--
Can't tweet, won't tweet!
_______________________________________________ Ibm-netrexx mailing list [hidden email]


--
Thomas Schneider (www.thsitc.com)

_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]





--
Saludos / Regards,
David Requena


_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/




_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Sending e-mails from a NetRexx application.

Robert L Hamilton
I put mail.jar in . . .\JRE\LIB\ext
 
Which is where tools.jar is located.
 
thanks
 
BobH

On Mon, Jun 6, 2011 at 12:09 PM, Robert Hamilton <[hidden email]> wrote:
NetRexx portable processor, version 2.05
Copyright (c) IBM Corporation, 2005.  All rights reserved.
Program MailSender.nrx
[E:\MISC\MailSender.nrx 29 42 13] Error: Unknown variable
Compilation of 'MailSender.nrx' failed [one error]
 
 
--3456789012345678901234567890123456789012345678901234567890
method sendEmail(mailTo=InternetAddress[(mailRecipient)], mailFrom, || -

   mailServer, || -
   mailSubject, mailBody) public static
 
Caracter 42 is the 'm' in 'mail'
 
Thanks for your time and enjoy the day
 
BobH
Richardson Texas USA

 
import java.util.
import javax.mail.
import javax.mail.internet.
import javax.activation.

class MailSender public

  method main(args=String[]) public static

    -- set these according to your needs
    mailServer    = "smtp.yourisp.net"
    mailFrom      = "[hidden email]"
    mailRecipient = "[hidden email]"
    -- an array, we could have several recipients
    mailTo = [InternetAddress(mailRecipient)]
    mailSubject = "Test E-Mail through NetRexx & Javamail"
    mailBody    = "This is a test of sending a" -
                  "plain text e-mail through NetRexx & Javamail.\n" || -
                  "Here is line 2."
                   
    sendEmail(mailTo, mailFrom, mailServer, mailSubject, mailBody)
        
        
  method sendEmail(mailTo=InternetAddress[], mailFrom, mailServer, mailSubject, mailBody) public static
        
    props = Properties()
    props.put("mail.smtp.host", String mailServer)
    -- log full exchange. this is quite verbose!!
    props.put("mail.debug", String "true")

    do

      msg = MimeMessage(Session.getInstance(props))
       
      msg.setFrom(InternetAddress(mailFrom))
      address = mailTo
      msg.setRecipients(Message.RecipientType.TO, address)
      msg.setSubject(mailSubject)
      msg.setSentDate(Date())
      msg.setText(mailBody)

      Transport.send(msg)

    catch mex=MessagingException
      mex.printStackTrace()
    end




2011/5/23 Robert Hamilton <[hidden email]>
I would also the thankful for a Leg Up on JavaMail/NetRexx

BobH


On Sun, May 22, 2011 at 11:23 AM, Thomas Schneider <[hidden email]> wrote:
Hello Alan & all,
   1.) Thanks to all who gave hints which way to go.
   2.) It looks, as a first glance, that JvaMail is exactly what I was searching for.
I'l have, however, have to learn again a lot after downloading the distribution.

Hence again one question, when allowed:

Does nyone of you have a resonable small NetRexx sample to SEND mails using JavaMail (written preferably in NetRexx) ?

Thomas.
======================================================
Am <a href="tel:21.05.2011%2020" target="_blank" value="+12105201120">21.05.2011 20:42, schrieb Alan Sampson:
JavaMail is the way to go, here's a link: http://www.oracle.com/technetwork/java/javamail/index.html.  Using the JavaMail API keeps your code "pure Java" and therefore "pure NetRexx" and doesn't pollute your application with external dependencies that may introduce licensing issues.

I've written several email based applications in Java using the JavaMail API for my employer so I can attest that the API is pretty easy to get on with (at least from a Java standpoint).  I'm certain it will be just as easy from NetRexx, just a SMOP.

Alan.


On 21 May 2011 05:19, Robert Hamilton <[hidden email]> wrote:
Tom; Get a copy of BLATT,  a command line program which can be run from Rexx and perhaps from NetRexx.  I think BLATT has been run from JAVA.

Bob Hamilton
Richardson Texas USA


On Sat, May 21, 2011 at 5:36 AM, Thomas Schneider <[hidden email]> wrote:
Hello there,
  for a customer application I'm currently writing I would need your help:

How can I *send* a series of e-mails  from a NetRexx application to a list of e-mail adresses?

There are for sure Java classes to do that, but I cannot find those in my books.

When anybody of you does have a sample of NetRexx (or Java) code
how to do that, please forward this sample to me!

Thanks in advance,
Thomas Schneider.

Thomas Schneider (www.thsitc.com)
_______________________________________________
Ibm-netrexx mailing list
[hidden email]



_______________________________________________
Ibm-netrexx mailing list
[hidden email]





--
Can't tweet, won't tweet!
_______________________________________________ Ibm-netrexx mailing list [hidden email]


--
Thomas Schneider (www.thsitc.com)

_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]





--
Saludos / Regards,
David Requena


_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]



_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Sending e-mails from a NetRexx application.

Robert L Hamilton
And Echo Classpath shows
 
.;C:\program files\java\jdk1.6.0_18\lib\tools.jar;
C:\Program Files\NetRexx\lib\NetRexxC.jar
 
BobH

On Mon, Jun 6, 2011 at 12:39 PM, Robert Hamilton <[hidden email]> wrote:
I put mail.jar in . . .\JRE\LIB\ext
 
Which is where tools.jar is located.
 
thanks
 
BobH

On Mon, Jun 6, 2011 at 12:09 PM, Robert Hamilton <[hidden email]> wrote:
NetRexx portable processor, version 2.05
Copyright (c) IBM Corporation, 2005.  All rights reserved.
Program MailSender.nrx
[E:\MISC\MailSender.nrx 29 42 13] Error: Unknown variable
Compilation of 'MailSender.nrx' failed [one error]
 
 
--3456789012345678901234567890123456789012345678901234567890
method sendEmail(mailTo=InternetAddress[(mailRecipient)], mailFrom, || -

   mailServer, || -
   mailSubject, mailBody) public static
 
Caracter 42 is the 'm' in 'mail'
 
Thanks for your time and enjoy the day
 
BobH
Richardson Texas USA

 
import java.util.
import javax.mail.
import javax.mail.internet.
import javax.activation.

class MailSender public

  method main(args=String[]) public static

    -- set these according to your needs
    mailServer    = "smtp.yourisp.net"
    mailFrom      = "[hidden email]"
    mailRecipient = "[hidden email]"
    -- an array, we could have several recipients
    mailTo = [InternetAddress(mailRecipient)]
    mailSubject = "Test E-Mail through NetRexx & Javamail"
    mailBody    = "This is a test of sending a" -
                  "plain text e-mail through NetRexx & Javamail.\n" || -
                  "Here is line 2."
                   
    sendEmail(mailTo, mailFrom, mailServer, mailSubject, mailBody)
        
        
  method sendEmail(mailTo=InternetAddress[], mailFrom, mailServer, mailSubject, mailBody) public static
        
    props = Properties()
    props.put("mail.smtp.host", String mailServer)
    -- log full exchange. this is quite verbose!!
    props.put("mail.debug", String "true")

    do

      msg = MimeMessage(Session.getInstance(props))
       
      msg.setFrom(InternetAddress(mailFrom))
      address = mailTo
      msg.setRecipients(Message.RecipientType.TO, address)
      msg.setSubject(mailSubject)
      msg.setSentDate(Date())
      msg.setText(mailBody)

      Transport.send(msg)

    catch mex=MessagingException
      mex.printStackTrace()
    end




2011/5/23 Robert Hamilton <[hidden email]>
I would also the thankful for a Leg Up on JavaMail/NetRexx

BobH


On Sun, May 22, 2011 at 11:23 AM, Thomas Schneider <[hidden email]> wrote:
Hello Alan & all,
   1.) Thanks to all who gave hints which way to go.
   2.) It looks, as a first glance, that JvaMail is exactly what I was searching for.
I'l have, however, have to learn again a lot after downloading the distribution.

Hence again one question, when allowed:

Does nyone of you have a resonable small NetRexx sample to SEND mails using JavaMail (written preferably in NetRexx) ?

Thomas.
======================================================
Am <a href="tel:21.05.2011%2020" target="_blank" value="+12105201120">21.05.2011 20:42, schrieb Alan Sampson:
JavaMail is the way to go, here's a link: http://www.oracle.com/technetwork/java/javamail/index.html.  Using the JavaMail API keeps your code "pure Java" and therefore "pure NetRexx" and doesn't pollute your application with external dependencies that may introduce licensing issues.

I've written several email based applications in Java using the JavaMail API for my employer so I can attest that the API is pretty easy to get on with (at least from a Java standpoint).  I'm certain it will be just as easy from NetRexx, just a SMOP.

Alan.


On 21 May 2011 05:19, Robert Hamilton <[hidden email]> wrote:
Tom; Get a copy of BLATT,  a command line program which can be run from Rexx and perhaps from NetRexx.  I think BLATT has been run from JAVA.

Bob Hamilton
Richardson Texas USA


On Sat, May 21, 2011 at 5:36 AM, Thomas Schneider <[hidden email]> wrote:
Hello there,
  for a customer application I'm currently writing I would need your help:

How can I *send* a series of e-mails  from a NetRexx application to a list of e-mail adresses?

There are for sure Java classes to do that, but I cannot find those in my books.

When anybody of you does have a sample of NetRexx (or Java) code
how to do that, please forward this sample to me!

Thanks in advance,
Thomas Schneider.

Thomas Schneider (www.thsitc.com)
_______________________________________________
Ibm-netrexx mailing list
[hidden email]



_______________________________________________
Ibm-netrexx mailing list
[hidden email]





--
Can't tweet, won't tweet!
_______________________________________________ Ibm-netrexx mailing list [hidden email]


--
Thomas Schneider (www.thsitc.com)

_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]





--
Saludos / Regards,
David Requena


_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Sending e-mails from a NetRexx application.

David Requena
In reply to this post by Robert L Hamilton
Bob,

Put the jar file wherever and enter its path in the field labelled 'Classpath' at the top of NetRexxDE's panel. If you click on the 'Classpath' label itself, you can set the path by just browsing to the jar file with an explorer interface.

HTH!

-
Saludos / Kind regards,
David Requena

NOTE: The opinions expressed here represent the opinions
of the authors and do not necessarily represent the opinions
of those who hold other opinions.

-----Original Message-----
From: Robert Hamilton <[hidden email]>
Sender: [hidden email]
Date: Mon, 6 Jun 2011 12:39:27
To: IBM Netrexx<[hidden email]>
Reply-To: IBM Netrexx <[hidden email]>
Subject: Re: [Ibm-netrexx] Sending e-mails from a NetRexx application.

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/



_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Sending e-mails from a NetRexx application.

alansam
In reply to this post by Robert L Hamilton
Just for laffs , here's a (slightly) better mousetrap:

/* NetRexx */
options replace format comments java crossref savelog symbols


import java.util.
import javax.mail.
import javax.mail.internet.
import javax.activation.

/**
 * Simple NetRexx JavaMail sample demonstrating sending mail via lists of email recipients.
 * Displays the use of 'Mail To', 'CC' and 'BCc' addressing
 *
 * @author Alan Sampson
 * @author David Requena
 * @version 1.0
 * @see <a href="http://www.oracle.com/technetwork/java/javamail/index.html">http://www.oracle.com/technetwork/java/javamail/index.html</a>
 */
class MailSenderList public

  -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /**
   * @param args
   */
  method main(args = String[]) public static

    -- set these according to your needs
    mailServer = "
smtp.yourisp.net"
    mailFrom   = '"Little Me" <little.me@example.com>'

    -- mailTo, mailCc an mailBCc must be a comma separated list of email addresses
    mailTo  = '"Ann Other" <ann.other@
example.com>, "Justin Other" <[hidden email]>'
    mailCc  = '"Interested Party" <[hidden email]>'
    mailBCc = '"Ivan Interest" <[hidden email]>'

    mailSubject = "Test E-Mail through NetRexx & Javamail"
    mailBody    = "This is a test of sending a" -
                  "plain text e-mail through NetRexx & Javamail.\n" || -
                  "Here is line 2."

    sendEmail(mailTo, mailCc, mailBCc, mailFrom, mailServer, mailSubject, mailBody)

    return

  -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /**
   * @param mailTo
   * @param mailFrom
   * @param mailServer
   * @param mailSubject
   * @param mailBody
   */
  method sendEmail(mailTo, mailCc, mailBCc, mailFrom, mailServer, mailSubject, mailBody) public static

    props = Properties()
    props.put("mail.smtp.host", String mailServer)
    -- log full exchange. this is quite verbose!!
    props.put("mail.debug", String "true")

    do

      msg = MimeMessage(Session.getInstance(props))

      if mailTo  = null then mailTo  = ''
      if mailCc  = null then mailCc  = ''
      if mailBCc = null then mailBCc = ''

      msg.setFrom(InternetAddress(mailFrom))
      if mailTo.length > 0 then do
        msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(mailTo))
        end
      if mailCc.length > 0 then do
        msg.setRecipients(Message.RecipientType.CC, InternetAddress.parse(mailCc))
        end
      if mailBCc.length > 0 then do
        msg.setRecipients(Message.RecipientType.BCC, InternetAddress.parse(mailBCc))
        end
      msg.setSubject(mailSubject)
      msg.setSentDate(Date())
      msg.setText(mailBody)

      Transport.send(msg)

    catch mex = MessagingException
      mex.printStackTrace()
    end

    return

-- =============================================================================
-- End of module
-- =============================================================================


Alan.

On 6 June 2011 10:45, Robert Hamilton <[hidden email]> wrote:
And Echo Classpath shows
 
.;C:\program files\java\jdk1.6.0_18\lib\tools.jar;
C:\Program Files\NetRexx\lib\NetRexxC.jar
 
BobH

On Mon, Jun 6, 2011 at 12:39 PM, Robert Hamilton <[hidden email]> wrote:
I put mail.jar in . . .\JRE\LIB\ext
 
Which is where tools.jar is located.
 
thanks
 
BobH

On Mon, Jun 6, 2011 at 12:09 PM, Robert Hamilton <[hidden email]> wrote:
NetRexx portable processor, version 2.05
Copyright (c) IBM Corporation, 2005.  All rights reserved.
Program MailSender.nrx
[E:\MISC\MailSender.nrx 29 42 13] Error: Unknown variable
Compilation of 'MailSender.nrx' failed [one error]
 
 
--3456789012345678901234567890123456789012345678901234567890
method sendEmail(mailTo=InternetAddress[(mailRecipient)], mailFrom, || -

   mailServer, || -
   mailSubject, mailBody) public static
 
Caracter 42 is the 'm' in 'mail'
 
Thanks for your time and enjoy the day
 
BobH
Richardson Texas USA

 
import java.util.
import javax.mail.
import javax.mail.internet.
import javax.activation.

class MailSender public

  method main(args=String[]) public static

    -- set these according to your needs
    mailServer    = "smtp.yourisp.net"
    mailFrom      = "[hidden email]"
    mailRecipient = "[hidden email]"
    -- an array, we could have several recipients
    mailTo = [InternetAddress(mailRecipient)]
    mailSubject = "Test E-Mail through NetRexx & Javamail"
    mailBody    = "This is a test of sending a" -
                  "plain text e-mail through NetRexx & Javamail.\n" || -
                  "Here is line 2."
                   
    sendEmail(mailTo, mailFrom, mailServer, mailSubject, mailBody)
        
        
  method sendEmail(mailTo=InternetAddress[], mailFrom, mailServer, mailSubject, mailBody) public static
        
    props = Properties()
    props.put("mail.smtp.host", String mailServer)
    -- log full exchange. this is quite verbose!!
    props.put("mail.debug", String "true")

    do

      msg = MimeMessage(Session.getInstance(props))
       
      msg.setFrom(InternetAddress(mailFrom))
      address = mailTo
      msg.setRecipients(Message.RecipientType.TO, address)
      msg.setSubject(mailSubject)
      msg.setSentDate(Date())
      msg.setText(mailBody)

      Transport.send(msg)

    catch mex=MessagingException
      mex.printStackTrace()
    end




2011/5/23 Robert Hamilton <[hidden email]>
I would also the thankful for a Leg Up on JavaMail/NetRexx

BobH


On Sun, May 22, 2011 at 11:23 AM, Thomas Schneider <[hidden email]> wrote:
Hello Alan & all,
   1.) Thanks to all who gave hints which way to go.
   2.) It looks, as a first glance, that JvaMail is exactly what I was searching for.
I'l have, however, have to learn again a lot after downloading the distribution.

Hence again one question, when allowed:

Does nyone of you have a resonable small NetRexx sample to SEND mails using JavaMail (written preferably in NetRexx) ?

Thomas.
======================================================
Am <a href="tel:21.05.2011%2020" value="+12105201120" target="_blank">21.05.2011 20:42, schrieb Alan Sampson:
JavaMail is the way to go, here's a link: http://www.oracle.com/technetwork/java/javamail/index.html.  Using the JavaMail API keeps your code "pure Java" and therefore "pure NetRexx" and doesn't pollute your application with external dependencies that may introduce licensing issues.

I've written several email based applications in Java using the JavaMail API for my employer so I can attest that the API is pretty easy to get on with (at least from a Java standpoint).  I'm certain it will be just as easy from NetRexx, just a SMOP.

Alan.


On 21 May 2011 05:19, Robert Hamilton <[hidden email]> wrote:
Tom; Get a copy of BLATT,  a command line program which can be run from Rexx and perhaps from NetRexx.  I think BLATT has been run from JAVA.

Bob Hamilton
Richardson Texas USA


On Sat, May 21, 2011 at 5:36 AM, Thomas Schneider <[hidden email]> wrote:
Hello there,
  for a customer application I'm currently writing I would need your help:

How can I *send* a series of e-mails  from a NetRexx application to a list of e-mail adresses?

There are for sure Java classes to do that, but I cannot find those in my books.

When anybody of you does have a sample of NetRexx (or Java) code
how to do that, please forward this sample to me!

Thanks in advance,
Thomas Schneider.

Thomas Schneider (www.thsitc.com)
_______________________________________________
Ibm-netrexx mailing list
[hidden email]



_______________________________________________
Ibm-netrexx mailing list
[hidden email]





--
Can't tweet, won't tweet!

_______________________________________________ Ibm-netrexx mailing list [hidden email]


--
Thomas Schneider (www.thsitc.com)

_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]





--
Saludos / Regards,
David Requena


_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/





--
Can't tweet, won't tweet!

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Alan

--
Needs more cowbell.
Reply | Threaded
Open this post in threaded view
|

Re: Sending e-mails from a NetRexx application.

David Requena
In reply to this post by Fernando Cassia-2
Fernando,

That code snipped pretended to be just a quick sample of how to use the library. After all it was a head start what was asked for :-) Going into all the details on the miriad different SASL auth algorithms, TLS and SSL transports, etc. is out of the scope of the sample (and my available time!)

As Alan demonstrates elsewhere on this thread it is possible to build upon this code.


2011/6/6 Fernando Cassia <[hidden email]>
On Mon, May 23, 2011 at 12:32, David Requena <[hidden email]> wrote:
>
> This is the simplest example I could come with (actualy a ported java
> example). Just text email, no attachments, mime/multipart, cryptography or
> anything fancy, which you can do with javamail.

Many thanks. However, how do you specify the smpt user name and
password? additinal parameters to Javamail?. And SSL and port number?

(I know, I should look up the javamail docs, but if you answer on this
thread it´ll be properly indexed and easier to find in the future ;)

TIA
FC

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/




--
Saludos / Regards,
David Requena


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Sending e-mails from a NetRexx application.

Fernando Cassia-2
On Tue, Jun 7, 2011 at 04:04, David Requena <[hidden email]> wrote:
>
> That code snipped pretended to be just a quick sample of how to use the
> library. After all it was a head start what was asked for :-) Going into all
> the details on the miriad different SASL auth algorithms, TLS and SSL
> transports, etc. is out of the scope of the sample (and my available time!)

And I thank you for that!. I´m sure Javamail however manages to
obscure most of the complexity. After all, my needs are quite simple:
ssl/tls connection to a given port, and standard username/password
authentication, as used by GMail.

Thanks
FC

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Sending e-mails from a NetRexx application.

David Requena
OK, here you go. David's crude html formated email sending through gmail sample. Enjoy modifying it :-)

import java.util.
import javax.mail.
import javax.mail.internet.
import javax.activation.

class GMailSender public
   
  properties static
    GMAIL_SMTP_SERVER = "smtp.gmail.com"
    GMAIL_TLS_PORT = 587
       

  method main(args=String[]) public static

    -- set these according to your needs
    username      = "[hidden email]"
    password      = "your_gmail_password"
    mailSender    = "[hidden email]" --can be whatever..
    mailRecipient = "[hidden email]"
   
    mailSubject   = "Test MIME E-Mail through NetRexx & Javamail"
    mailBody      = "<p>This is a test of sending a" -
                    "<u><i>MIME format e-mail</i></u> through Gmail using" -
                    "<b>NetRexx & Javamail.</b><br/></p>" -
                    "<p>Here is line 2.</p>" -
                    "<p><center>And here's an inlined external image</center>" -
                    "<br><center><img src='http://publib.boulder.ibm." || -
                    "com/infocenter/iseries/v5r3/topic/rzatz/51/program" || -
                    "/rzaiz523.gif' alt='Description of JavaMail APIs'" -
                    "height='299' width='362'></center></p>" -
                    "Attachments deliverately left as an exercice for the" -
                    "reader :-)"


    mailFrom = InternetAddress(mailSender)
    mailTo = [InternetAddress(mailRecipient)]                  
   
    sendGmail(mailTo, mailFrom, mailSubject, mailBody, username, password)
       
       
  method sendGmail( -
        mailTo=InternetAddress[], -
        mailFrom=InternetAddress, -
        mailSubject, -
        mailBody, -
        username, -
        password) -
        public static
       
    props = Properties()
    props.put("mail.debug", String "true")
    props.put("mail.smtp.auth", String "true");
    props.put("mail.smtp.starttls.enable", String "true")

    do

      mailSession = Session.getInstance(props)
      msg = MimeMessage(mailSession)
      
      msg.setFrom(mailFrom)
      msg.setRecipients(Message.RecipientType.TO, mailTo)
      msg.setSentDate(Date())
      msg.setSubject(mailSubject)
      msg.setText(mailBody, "UTF-8", "html")

      mailTransport = mailSession.getTransport("smtp")
      mailTransport.connect(GMAIL_SMTP_SERVER, GMAIL_TLS_PORT, username, password)
     
      mailTransport.sendMessage(msg, msg.getAllRecipients())

    catch mex=MessagingException
      mex.printStackTrace()
    end


2011/6/7 Fernando Cassia <[hidden email]>
On Tue, Jun 7, 2011 at 04:04, David Requena <[hidden email]> wrote:
>
> That code snipped pretended to be just a quick sample of how to use the
> library. After all it was a head start what was asked for :-) Going into all
> the details on the miriad different SASL auth algorithms, TLS and SSL
> transports, etc. is out of the scope of the sample (and my available time!)

And I thank you for that!. I´m sure Javamail however manages to
obscure most of the complexity. After all, my needs are quite simple:
ssl/tls connection to a given port, and standard username/password
authentication, as used by GMail.

Thanks
FC

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/




--
Saludos / Regards,
David Requena


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

12