KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > javax > mail > MessagingException

javax.mail
Class MessagingException

java.lang.Object
  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended byjavax.mail.MessagingException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AuthenticationFailedException, FolderClosedException, FolderNotFoundException, IllegalWriteException, MessageRemovedException, MethodNotSupportedException, NoSuchProviderException, ParseException, ReadOnlyFolderException, SearchException, SendFailedException, StoreClosedException
See Also:
Top Examples, Source Code

public String getMessage()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Exception getNextException()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public MessagingException()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public MessagingException(String s)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1964]Email sending Code
By anand_gu { at } hotmail { dot } com on 2008/05/03 03:40:08  Rate
package com.sty.frontend.bizact.accounts; 
  
  
 import javax.mail.*; 
 import javax.mail.internet.*; 
 import java.util.*;  
  
  
 public class mail {  
    
    
   public static void main ( String args [  ]  ) throws Exception 
    {  
     String args1 [  ] = { "Annad.G@xxx.com" } ; 
      
     postMail ( args1,"Hai","34343","anand.g@xxx.com" ) ; 
    
      
    }  
 public static void postMail (  String recipients [   ] , String subject, String message , String from )  throws MessagingException 
  {  
     boolean debug = false; 
  
  
      //Set the host smtp address 
      Properties props = new Properties (  ) ; 
      props.put ( "mail.smtp.host", "104.237.5.145" ) ; 
  
  
     // create some properties and get the default Session 
     Session session = Session.getDefaultInstance ( props, null ) ; 
     session.setDebug ( debug ) ; 
  
  
     // create a message 
     Message msg = new MimeMessage ( session ) ; 
  
  
     // set the from and to address 
     InternetAddress addressFrom = new InternetAddress ( from ) ; 
     msg.setFrom ( addressFrom ) ; 
  
  
     InternetAddress [  ]  addressTo = new InternetAddress [ recipients.length ] ;  
     for  ( int i = 0; i  <  recipients.length; i++ )  
      {  
         addressTo [ i ]  = new InternetAddress ( recipients [ i ]  ) ; 
      }  
     msg.setRecipients ( Message.RecipientType.TO, addressTo ) ; 
     
  
  
     // Optional : You can also set your custom headers in the Email if you Want 
     msg.addHeader ( "MyHeaderName", "myHeaderValue" ) ; 
  
  
     // Setting the Subject and Content Type 
     msg.setSubject ( subject ) ; 
     msg.setContent ( message, "text/plain" ) ; 
     Transport.send ( msg ) ; 
  }  
    
  } 


public MessagingException(String s,
                          Exception e)
See Also:
setNextException(java.lang.Exception), getNextException()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean setNextException(Exception ex)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags