× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



To pass many addresses you can also use this

msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to));

the (to) will by by example "me@xxxxxxxxxx, you@xxxxxxxxxx"

Edouard Lanteigne
Abbott Laboratories (Canada),  Systems Analyst
Tel: (514) 832-7124    Fax: (514) 832-7833
E-mail : edouard.lanteigne@xxxxxxxxxx
http://www.abbott.ca








"Colin Williams" <colin.williams@xxxxxxxxxxxx>
Sent by: java400-l-bounces@xxxxxxxxxxxx
05/06/04 03:51 PM
Please respond to Java Programming on and around the iSeries / AS400

 
        To:     "Java Programming on and around the iSeries / AS400" 
<java400-l@xxxxxxxxxxxx>
        cc: 
        Subject:        Re: sendmail


Eric,

this code appears to be only using the To, as you describe, set on the 
line

// Set the to address
>    message.addRecipient(Message.RecipientType.TO, new
InternetAddress(to));

the way I implemented a javamail client, was to pass three seperate object
arrays as parameters, so instead of what you have

String to       = args[1];

which i presume is receiving an recipient email address, but no recipient
name, i have

Object[] to;

Object[] toname;

Object[] totype;



to = (Object[])args[0];

toname = (Object[])args[1];

totype = (Object[])args[2];



This way I can pass in a list of recipient email address's, recipient 
names,
and recipient types (to,cc or bcc). I use the following loop to process 
the
addresses

// Set to Addresses

for (int i=0;i < to.length;i++) {


if (to[i]!=null) {

tempString = (String)to[i];

thisAddress.setAddress(tempString);

tempString = (String)toname[i];

thisAddress.setPersonal(tempString);


if (((String)totype[i]).equals("0"))

msg.addRecipient(Message.RecipientType.TO, thisAddress);

if (((String)totype[i]).equals("1"))

msg.addRecipient(Message.RecipientType.CC, thisAddress);

if (((String)totype[i]).equals("2"))

msg.addRecipient(Message.RecipientType.BCC, thisAddress);

}

}

cheers

Colin.W


----- Original Message ----- 
From: "Eric Kempter" <EKempter@xxxxxxxxxxxxxxx>
To: <JAVA400-L@xxxxxxxxxxxx>
Sent: Thursday, May 06, 2004 6:32 PM
Subject: sendmail


> Newbie question ahead.
> I have successfully  implemented JavaMail on our IBM V5R2 iseries 
(I5/OS).
The JavaMail class uses sendmail to send email but I noticed that there is
no argument for cc or bcc.  I assume that sendmail is a class and 
contained
in a package.  My question is, how do I determine what (other) arguments
sendmail will accept?  How do I determine what package sendmail is 
included
in?  The following is the JavaMail source.  Thanks in advance for any
assistance.
>
>
/***************************************************************************
****************
> Date       : 11/02/2001
> Programmer : James Zhang
> Desc       : Practice the javamail.
>
****************************************************************************
****************/
> import java.util.Properties;
> import javax.mail.*;
> import javax.mail.internet.*;
> import java.io.*;
>
> public class JavaMailMIME {
>   public static void main (String args[]) throws Exception {
>
>     String from     = args[0];
>     String to       = args[1];
>     String replyTo  = args[2];
>     String subject  = args[3];
>     String text     = args[4];
> short returnCode = 0;
> try{
> returnCode = sendMail(from,to,replyTo,subject,text);
> }catch(Exception e){
> e.printStackTrace();
> }
> }
>
>   public static short sendMail (String from, String to, String replyTo,
>                                 String subject,String text) throws
Exception {
> try{
> //get the properties
> FileInputStream emailPropertyFile;
> //get the properties
> Properties emailProperty = new Properties();
> try{
> emailPropertyFile = new FileInputStream("JavaMail.properties");
> }catch(FileNotFoundException e){
> //JZEmail.properties not found
> return 100;
> }
> emailProperty.load(emailPropertyFile);
> emailPropertyFile.close();
>
> //String host = "SMTP.RICAINS.COM";
> String hostName = emailProperty.getProperty("email.hostname");
> String hostType = emailProperty.getProperty("email.hosttype");
>
>     // Get system properties
>     Properties systemProperty = System.getProperties();
>
>     // Setup mail server
>     systemProperty.put(hostType, hostName);
>
>     // Get session
>     Session session = Session.getDefaultInstance(systemProperty, null);
> //Session session = Session.getInstance(systemProperty, null);
>
>     // Define message
>     MimeMessage message = new MimeMessage(session);
>
>   // Set the from address
>    message.setFrom(new InternetAddress(from));
>
>    // Set the to address
>    message.addRecipient(Message.RecipientType.TO, new
InternetAddress(to));
>
>    // Set the subject
>    message.setSubject(subject);
>
>    // Set the content
>    message.setContent(text, "text/html");
>
>    // Set the reply to
>    replyTo = replyTo.trim();
>    if(replyTo != null && !replyTo.equals("")){
>    InternetAddress ReplyTo[] = new InternetAddress[1];
>    ReplyTo[0] = new InternetAddress(replyTo);
>    message.setReplyTo(ReplyTo);
>    }
>
>    // Send message
>    Transport.send(message);
>
>    }catch(MessagingException me){
> // search for the real exception that caused the problem
> Exception realException = me;
> while ( (realException instanceof MessagingException) &&
> ((MessagingException)realException).getNextException() != null) {
> realException = ((MessagingException)realException).getNextException();
> }
>
> // map the exceptions to error codes
> if (realException instanceof javax.mail.MessagingException)
> return 101;
> else if (realException instanceof java.net.ConnectException)
> return 102;
> else if (realException instanceof java.net.UnknownHostException)
> return 103;
>
> }catch(Exception e){
>     // filename is not found
>     //e.printStackTrace();
> return 999;
> }
>     return 0;
>   }
> }
>
> _______________________________________________
> This is the Java Programming on and around the iSeries / AS400 
(JAVA400-L)
mailing list
> To post a message email: JAVA400-L@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/java400-l
> or email: JAVA400-L-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/java400-l.
>
>


This e-mail has been sent by a company of Bertram Group Ltd, whose 
registered office is The Nest, Rosary Road Norwich NR1 1TF. 
This message, and any attachments, are intended solely for the addressee 
and may contain privileged or confidential information.  If you are not 
the intended recipient, any disclosure, copying, distribution or any 
action taken or omitted to be taken in reliance on it, is prohibited and 
may be unlawful.  If you believe that you have received this email in 
error, please contact the sender immediately. Opinions, conclusions and 
statements of intent in this e-mail are those of the sender and will not 
bind a Bertram Group Ltd company unless confirmed in writing by a director 
independently of this message. 
Although we have taken steps to ensure that this email and any attachments 
are free from any virus, we advise that in keeping with good computing 
practice the recipient should ensure they are actually virus free.

_______________________________________________
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) 
mailing list
To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.




As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.