java.lang.Object
javax.mail.Address
javax.mail.internet.InternetAddress
- All Implemented Interfaces:
- Cloneable, Serializable
- See Also:
- Top Examples, Source Code
protected String address
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[227]Send confidential mail
By Anonymous on 2005/04/26 15:26:23 Rate
import java.util.Date;
import java.util.Properties;
import javax.naming.*;
import javax.mail.*;
import javax.mail.internet.*;
....
// Local reference to the javax.mail.Session
javax.mail.Session mailSession = null;
try {
Context ctx = new InitialContext ( ) ;
// Get the properties from this bean from the environment. The
// properties were specified in the env-entry tags in the deployment
// descriptor for this bean
Context myEnv = ( Context ) ctx.lookup ( "java:comp/env" ) ;
String smtpHost = ( String ) myEnv.lookup ( "smtpHost" ) ;
Properties props = new Properties ( ) ;
props.put ( "mail.smtp.host", smtpHost ) ;
// Get a mail session. You would normally get this from
// JNDI, but some servers have a problem with this.
// Each Message Driven bean instance is responsible for
//getting its own unshared javax.mail.Session.
mailSession = javax.mail.Session.getDefaultInstance ( props, null ) ;
javax.mail.Message msg = new MimeMessage ( mailSession ) ;
// Set the mail properties
msg.setFrom ( new javax.mail.internet.InternetAddress ( "FromSomeone@KickJava.com" ) ;
InternetAddress [ ] addresses = {
new InternetAddress ( "ToSomeone@Kickjava.com" )
} ;
msg.setRecipients ( javax.mail.Message.RecipientType.TO, addresses ) ;
msg.setSubject ( "Subject" ) ;
msg.setSentDate ( new Date ( ) ) ;
// Create the body text
Multipart parts = new MimeMultipart ( ) ;
MimeBodyPart mainBody = new MimeBodyPart ( ) ;
mainBody.setText ( "Hello Body" ) ;
parts.addBodyPart ( mainBody ) ;
MimeBodyPart attachmentBody = new MimeBodyPart ( ) ;
attachmentBody.setText ( "This is text in the attachment" ) ;
attachmentBody.addBodyPart ( p2 ) ;
// Set some header fields
msg.setHeader ( "X-Priority", "High" ) ;
msg.setHeader ( "Sensitivity", "Company-Confidential" ) ;
msg.setContent ( parts ) ;
System.out.println ( "Sending mail to support@KickJava.com" ) ;
Transport.send ( msg ) ;
}
catch ( Exception ex ) {
ex.printStackTrace ( ) ;
}
finally {
mailSession = null;
}
public Object clone()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected String encodedPersonal
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public boolean equals(Object a)
- See Also:
- Address
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public String getAddress()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public InternetAddress[] getGroup(boolean strict)
throws AddressException- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static InternetAddress getLocalAddress(Session session)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public String getPersonal()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public String getType()
- See Also:
InternetAddress, Address
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int hashCode()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public InternetAddress()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public InternetAddress(String address)
throws AddressException- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public InternetAddress(String address,
boolean strict)
throws AddressException- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public InternetAddress(String address,
String personal)
throws UnsupportedEncodingException- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public InternetAddress(String address,
String personal,
String charset)
throws UnsupportedEncodingException- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public boolean isGroup()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static InternetAddress[] parse(String addresslist)
throws AddressException- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static InternetAddress[] parse(String addresslist,
boolean strict)
throws AddressException- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[861]Send SMTP mail
By Ankur on 2004/08/19 04:40:11 Rate
import java.io.*;
import java.util.Date;
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import oracle.jdbc.driver.OracleTypes;
import java.sql.*;
import javax.sql.*;
public class Mail
{
String mailhost;
String mailport;
String from;
String to;
String body;
String body1;
String to_usrid;
String from_usrid;
private til.util.dbpool.ConnectionPool connectDB = null;
public Mail ( String s String s1 )
{
to_usrid=s;
from_usrid=s1;
mailhost="localhost";
mailport="**";
subject="Urgent,your club may be deleted soon";
}
public void work ( )
{
try
{
String s = "";
s = to_usrid;
String s1 = "";
s1 = from_usrid;
BufferedReader bufferreader = new BufferReader ( new InputStreamReader ( System.in ) ) ;
java.util.Properties properties = System.getProperties ( ) ;
properties.put ( "mail.smtp.host", mailhost ) ;
properties.put ( "mail.smtp.port", mailport ) ;
Session session = Session.getInstance ( properties, null ) ;
MimeMessage mimemessage = new MimeMessage ( session ) ;
mimemessage.setFrom ( new InternetAddress ( from ) ;
mimemessage.setRicipients ( new javax.mail.Message.RecipientType.To, InternetAddress.parse ( s,false ) ) ;
mimemessage.setSubject ( subject ) ;
format ( message ) ;
mimemessage.setSentDate ( new Date ( ) ) ;
Transport.send ( mimemessage ) ;
System.out.println ( "**************Mail has been send successfully**************" ) ;
}
catch ( Exception ex )
{
System.out.println ( "Exception Caught ex" ) ;
ex.printStackTrace ( ) ;
}
public static InternetAddress[] parseHeader(String addresslist,
boolean strict)
throws AddressException- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected String personal
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setAddress(String address)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setPersonal(String name)
throws UnsupportedEncodingException- See Also:
setPersonal(String name, String charset)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setPersonal(String name,
String charset)
throws UnsupportedEncodingException- See Also:
setPersonal(String)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public String toString()
- See Also:
- Address
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static String toString(Address[] addresses)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static String toString(Address[] addresses,
int used)- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public String toUnicodeString()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void validate()
throws AddressException- Geek's Notes:
- Description Add your codes or notes Search More Java Examples