All Packages Class Hierarchy This Package Previous Next Index
Class datarep.common.Email
java.lang.Object
|
+----datarep.common.Email
- public class Email
- extends Object
Email is a class which lets you send E-mail from within a java program.
It requires acess to a SMTP server.
To sucessfully send E-mail, you must call the setServer, setTo and setFrom methods. The E-mail
will be useful if the setSubject and setMessage methods are also called. Finally, be sure to
call the send method, which actually sends the message.
- Version:
- 1.2
- Author:
- Data Representations, Inc.
-
Email()
-
-
getFrom()
- returns the current sender of the message.
-
getLastConversation()
- returns the log of the messages sent to and from the SMTP server.
-
getMessage()
- returns the current message.
-
getPort()
- returns the current port.
-
getServer()
- returns the current server.
-
getSubject()
- returns the current subject of the message.
-
getTo()
- returns the current recipient of the message.
-
send()
-
You must use the send() message to actually send the E-mail message.
-
setAdditionalHeaders(String)
- sets other headers
-
setFrom(String)
- sets who the message is from.
-
setMessage(String)
- sets the message to be sent.
-
setServer(String)
- sets the SMTP server.
-
setServer(String, int)
- sets the SMTP server and port.
-
setSubject(String)
- sets the subject.
-
setTimeout(int)
- sets the timeout in milliseconds for the socket.
-
setTo(String)
- sets who the message is to.
Email
public Email()
setServer
public void setServer(String smtp)
- sets the SMTP server.
setServer
public void setServer(String smtp,
int port)
- sets the SMTP server and port. The default port is 25.
setTimeout
public void setTimeout(int timeout)
- sets the timeout in milliseconds for the socket. The default is 60,000 (60 seconds)
setFrom
public void setFrom(String from)
- sets who the message is from. This should be a valid E-mail address.
setTo
public void setTo(String to)
- sets who the message is to. This should be a valid E-mail address.
setSubject
public void setSubject(String subject)
- sets the subject. This may be blank.
setMessage
public void setMessage(String message)
- sets the message to be sent.
setAdditionalHeaders
public void setAdditionalHeaders(String otherHeaders)
- sets other headers
getServer
public String getServer()
- returns the current server.
getPort
public int getPort()
- returns the current port.
getFrom
public String getFrom()
- returns the current sender of the message.
getTo
public String getTo()
- returns the current recipient of the message.
getSubject
public String getSubject()
- returns the current subject of the message.
getMessage
public String getMessage()
- returns the current message.
getLastConversation
public String getLastConversation()
- returns the log of the messages sent to and from the SMTP server.
send
public void send() throws IOException, UnknownHostException
- You must use the send() message to actually send the E-mail message. Be sure that the
SMTP server has already been set, as well as the to, from, subject, and message of the E-mail.
- Throws: IOException
- throws IOException if there is an error sending or receiving
information from the SMTP server.
- Throws: UnknownHostException
- throws this exception if the host is unknown.
All Packages Class Hierarchy This Package Previous Next Index