× 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.



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;
  }
}


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.