jasp.jmail
Class Message

java.lang.Object
  extended byjasp.jmail.Message

public class Message
extends java.lang.Object

This class implements the Jmail.Message in java.


Constructor Summary
Message()
          Creates a Message object.
 
Method Summary
 java.lang.String About()
          Some useful information
 java.lang.String AddAttachment(java.lang.String filename, boolean isinline, java.lang.String contenttype)
          Add a file attachment to the message, if InLIne is set to TRUE, the attachement will be added as an inline attachement and addAttachement() returns the content id.
 java.lang.String AddCustomAttachment(java.lang.String file, java.lang.String data, boolean isinline)
          Adds a custom attachment.
 void AddHeader(java.lang.String xheader, java.lang.String value)
          Adds a user defined X-Header to the message
 void AddNativeHeader(java.lang.String header, java.lang.String value)
          Customer Headers
 void AddRecipient(java.lang.String email)
           
 void AddRecipient(java.lang.String email, java.lang.String name)
           
 void AddRecipient(java.lang.String email, java.lang.String name, java.lang.String pgpkey)
          Adds a recipient to the message
 void AddRecipientBCC(java.lang.String email)
           
 void AddRecipientBCC(java.lang.String email, java.lang.String PGPKey)
          Adds a blind carbon copy recipient to the message, AddRecipientBcc can be used multiple times for several recipients.
 void AddRecipientCC(java.lang.String email)
           
 void AddRecipientCC(java.lang.String email, java.lang.String name)
           
 void AddRecipientCC(java.lang.String email, java.lang.String name, java.lang.String pgpkey)
          Adds a carbon copy recipient to the message, AddRecipientCC can be used multiple times for serveral recipients.
 java.lang.String AddURLAttachment(java.lang.String url, java.lang.String attachas)
           
 java.lang.String AddURLAttachment(java.lang.String url, java.lang.String attachas, boolean isinline)
           
 java.lang.String AddURLAttachment(java.lang.String url, java.lang.String attachas, boolean isinline, java.lang.String auth)
          Downloads and adds an attachment based on a URL. a seconds argument, "AttachAs", is used for specifying the filename that the attachment will receive in the message. if inLine is set to TRUE, the attacgment will be added as an inline attachment and addAttachment returns the content id, this is useful when sending HTML e-mails.
 void AppendBodyFromFile(java.lang.String file)
          Clears the body of the message and replaces it with the contents of the file.
 void AppendHTML(java.lang.String text)
          Append "Text" to HTML Body of the message
 void AppendText(java.lang.String t)
          Append "text" to body
 void Clear()
          Clears the message object, and gives you a new clean message
 void ClearAttachments()
          Clears the list of attachments.
 void ClearCustomHeaders()
          Clears all custom headers.
 void ClearRecipients()
          Clears the recipitent list
 void Close()
          Force JMail to close a chache connection to a mail server
 java.lang.String DecodeHeader(java.lang.String h)
          Decodes a message header
 void ExtractEmailAddressesFromURL(java.lang.String url)
           
 void ExtractEmailAddressesFromURL(java.lang.String url, java.lang.String auth)
          Downloads and adds e-mail addresses from a URL
 Attachments getAttachments()
          Returns the Attachments collection
 java.lang.String getBody()
          Returns the message's body
 java.lang.String getBodyText()
           
 java.lang.String getContentType()
          Returns the body's content-type
 java.lang.String getDate()
          Returns the Date Time when the message was sent.
 int getErrorCode()
          Contains the error code if message.slient is set to TRUE
 java.lang.String getErrorMessage()
          Contains the error message if message.slient is set to TRUE
 java.lang.String getErrorSource()
          Contains the error source if message.slient is set to TRUE.
 java.lang.String getFrom()
          The sender's e-mail address
 java.lang.String getFromName()
           
 Headers getHeaders()
          Returns the header's object.
 java.lang.String getHTMLBody()
           
 java.lang.String getLog()
           
 java.lang.String getMailData()
          The raw maildata as the e-mail will look like when it is delivered.
 java.lang.String getMailDomain()
           
 void GetMessageBodyFromURL(java.lang.String url)
           
 void GetMessageBodyFromURL(java.lang.String url, java.lang.String auth)
          Clear the body of the message and replaces it with the contents of the URL. the content type is automatically set to match the content type of the URL, the second argument(login and password) is optional.
 java.lang.String getMimeVersion()
           
 int getPriority()
           
 Recipients getRecipients()
          Returns the recipient's collection
 java.lang.String getRecipientsString()
          Readonly property of all recipients of this message
 java.lang.String getReplyTo()
           
 boolean getSilent()
           
 int getSize()
          Returns the total size of the message in bytes
 java.lang.String getSubject()
           
 java.lang.String getText()
          Return entire message source
 java.lang.String getVersion()
           
 java.lang.Object KeyInformation(java.lang.String keyidentifier)
          Returns a PGPKey object holding information for the keys matchnig the supplied identifier.
 void LoadFromStream(java.io.InputStream st)
          Loads a message form a stream .
 void LogCustomMessage(java.lang.String message)
          Logs a custom user message to the JMail log.
 void nq()
          Append the e-mail to the mail queue and returns
 void ParseMessage(java.lang.String messagesource)
          Parses a message .
 java.lang.Object PGPDecode(boolean decodebody, boolean decodeattachments)
          This method will decode the contents of the message object using PGP , It will decrypt the contents and verify and signatures.
 void SaveToStream(java.io.OutputStream stream)
          Saves the message source (RFC822 compatible message) to a stream
 boolean Send(java.lang.String mailserver)
           
 boolean Send(java.lang.String mailserver, boolean enque)
          Sends the message.
 void SendToNewsGroup(java.lang.String servername, java.lang.String newsgroups)
          Sends the message to NewsGroups(separated by a ",") using the NNTP server specified
 void setBody(java.lang.String body)
           
 void setCharset(java.lang.String charset)
          The charset to the message. the default is "US-ASCII".
 void setContentTransferEncoding(java.lang.String cod)
          Specifies the content transfer encoding. the defult is "Quoted-Printable".
 void setContentType(java.lang.String con)
           
 void setDate(java.util.Date d)
           
 void setDeferedDelivery(java.util.Date d)
          Sets deferred delivery of the messages. if the mail server supports it the message won't be delivered until this date and time.
 void setEnableCharsetTranslation(boolean en)
          Set to TRUE , which is the default.
 void setEncoding(java.lang.String en)
          This can be used to changed the default attachment encoding from base64.
 void setEncryptAttachments(boolean ea)
          Set to TRUE all attachments will be encrypted too if encryption is enabled. the default is TRUE.
 void setFrom(java.lang.String f)
           
 void setFromName(java.lang.String f)
           
 void setHTMLBody(java.lang.String h)
           
 void setISOEncodeHeaders(boolean b)
          Encodes header strings according to is-8859-1 character sets.
 void setLogging(boolean b)
           
 void setMailDomain(java.lang.String md)
           
 void setMailServerName(java.lang.String user)
           
 void setMailServerPassword(java.lang.String mp)
          Used to specify the password for SMTP server authentication if the mail server requires a user to login.
 void setMimeVersion(java.lang.String v)
          Specifies the mime version. the default is "1.0"
 void setMsPickupdirectory(java.lang.String p)
          The path to the pickup directory of MS SMTP server.
 void setPGPEncrypt(boolean b)
          Set to TRUE, the e-mail will be encrypted when the message is sent.
 void setPGPPassphrase(boolean b)
          The PGP passphrase used when signing
 void setPGPSign(boolean b)
          Set to TRUE, the e-mail will be signed when the message is sent, using PGP.
 void setPGPSignkey(java.lang.String key)
          An e-mail address or a PGP keu id identifying the key to be used for signing
 void setPopelining(boolean b)
          Override if JMail should use pipelining on a server that supports it
 void setPriority(int p)
          returns the message's priority. 3 is normal priority.
 void setReplyTo(java.lang.String e)
          Specifies an optional reply address
 void setReturnReceipt(boolean b)
          Specifies whether or not the sender requires a return receipt.
 void setSilent(boolean s)
          Set to True , JMAIL will not throw exceptions.
 void setSimpleLayout(boolean f)
          Set to TRUE to reduce the number of the headers JMAil produces.
 void setSubject(java.lang.String sub)
           
 boolean VerifyKeys(java.lang.String key)
          Returns True if ALL the supplied keys where found in the local keyring.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Message

public Message()
Creates a Message object.

Method Detail

AddAttachment

public java.lang.String AddAttachment(java.lang.String filename,
                                      boolean isinline,
                                      java.lang.String contenttype)
                               throws java.lang.Exception
Add a file attachment to the message, if InLIne is set to TRUE, the attachement will be added as an inline attachement and addAttachement() returns the content id. This is only useful when sending HTML e-mails.

Throws:
java.lang.Exception

AddCustomAttachment

public java.lang.String AddCustomAttachment(java.lang.String file,
                                            java.lang.String data,
                                            boolean isinline)
                                     throws java.lang.Exception
Adds a custom attachment. This can be used to attach "Virtual files" like a generated text string or certificate etc. If InLine is set to TRUE, the attachment will be added as an inline attachment and addAttachment() returns the content id , this is only useful when sending HTML e-mails.

Throws:
java.lang.Exception

AddHeader

public void AddHeader(java.lang.String xheader,
                      java.lang.String value)
Adds a user defined X-Header to the message


AddNativeHeader

public void AddNativeHeader(java.lang.String header,
                            java.lang.String value)
Customer Headers


AddRecipient

public void AddRecipient(java.lang.String email,
                         java.lang.String name,
                         java.lang.String pgpkey)
                  throws java.lang.Exception
Adds a recipient to the message

Throws:
java.lang.Exception

AddRecipient

public void AddRecipient(java.lang.String email,
                         java.lang.String name)

AddRecipient

public void AddRecipient(java.lang.String email)

AddRecipientBCC

public void AddRecipientBCC(java.lang.String email,
                            java.lang.String PGPKey)
                     throws java.lang.Exception
Adds a blind carbon copy recipient to the message, AddRecipientBcc can be used multiple times for several recipients. RecipientName is optional. PGPKey is optional if not supplued and PGPEncryption is set to TRUE, it will default to emailAddress

Throws:
java.lang.Exception

AddRecipientBCC

public void AddRecipientBCC(java.lang.String email)
                     throws java.lang.Exception
Throws:
java.lang.Exception

AddRecipientCC

public void AddRecipientCC(java.lang.String email,
                           java.lang.String name,
                           java.lang.String pgpkey)
                    throws java.lang.Exception
Adds a carbon copy recipient to the message, AddRecipientCC can be used multiple times for serveral recipients. RecipientName is optional , PGPKEy is optional , if not supplied and PGPencryption is set to TURE, it will default to emailAddress

Throws:
java.lang.Exception

AddRecipientCC

public void AddRecipientCC(java.lang.String email)
                    throws java.lang.Exception
Throws:
java.lang.Exception

AddRecipientCC

public void AddRecipientCC(java.lang.String email,
                           java.lang.String name)
                    throws java.lang.Exception
Throws:
java.lang.Exception

AddURLAttachment

public java.lang.String AddURLAttachment(java.lang.String url,
                                         java.lang.String attachas,
                                         boolean isinline,
                                         java.lang.String auth)
                                  throws java.lang.Exception
Downloads and adds an attachment based on a URL. a seconds argument, "AttachAs", is used for specifying the filename that the attachment will receive in the message. if inLine is set to TRUE, the attacgment will be added as an inline attachment and addAttachment returns the content id, this is useful when sending HTML e-mails. A last and ] optional argument is used for optional www-Authentication.

Throws:
java.lang.Exception

AddURLAttachment

public java.lang.String AddURLAttachment(java.lang.String url,
                                         java.lang.String attachas)
                                  throws java.lang.Exception
Throws:
java.lang.Exception

AddURLAttachment

public java.lang.String AddURLAttachment(java.lang.String url,
                                         java.lang.String attachas,
                                         boolean isinline)
                                  throws java.lang.Exception
Throws:
java.lang.Exception

AppendBodyFromFile

public void AppendBodyFromFile(java.lang.String file)
Clears the body of the message and replaces it with the contents of the file.


AppendHTML

public void AppendHTML(java.lang.String text)
Append "Text" to HTML Body of the message


AppendText

public void AppendText(java.lang.String t)
Append "text" to body


Clear

public void Clear()
Clears the message object, and gives you a new clean message


ClearAttachments

public void ClearAttachments()
Clears the list of attachments.


ClearCustomHeaders

public void ClearCustomHeaders()
Clears all custom headers.


ClearRecipients

public void ClearRecipients()
Clears the recipitent list


Close

public void Close()
Force JMail to close a chache connection to a mail server


DecodeHeader

public java.lang.String DecodeHeader(java.lang.String h)
                              throws java.lang.Exception
Decodes a message header

Throws:
java.lang.Exception

ExtractEmailAddressesFromURL

public void ExtractEmailAddressesFromURL(java.lang.String url,
                                         java.lang.String auth)
Downloads and adds e-mail addresses from a URL


ExtractEmailAddressesFromURL

public void ExtractEmailAddressesFromURL(java.lang.String url)

GetMessageBodyFromURL

public void GetMessageBodyFromURL(java.lang.String url,
                                  java.lang.String auth)
Clear the body of the message and replaces it with the contents of the URL. the content type is automatically set to match the content type of the URL, the second argument(login and password) is optional.


GetMessageBodyFromURL

public void GetMessageBodyFromURL(java.lang.String url)

KeyInformation

public java.lang.Object KeyInformation(java.lang.String keyidentifier)
Returns a PGPKey object holding information for the keys matchnig the supplied identifier.


LoadFromStream

public void LoadFromStream(java.io.InputStream st)
                    throws java.lang.Exception
Loads a message form a stream . Note the stream data must be compatible with the message format described in RFC822.

Throws:
java.lang.Exception

LogCustomMessage

public void LogCustomMessage(java.lang.String message)
                      throws java.lang.Exception
Logs a custom user message to the JMail log. This function works only if logging is set to TRUE.

Throws:
java.lang.Exception

nq

public void nq()
Append the e-mail to the mail queue and returns


ParseMessage

public void ParseMessage(java.lang.String messagesource)
Parses a message . MessageSource must be compatilible with message format descrubed in RFC822.


SaveToStream

public void SaveToStream(java.io.OutputStream stream)
Saves the message source (RFC822 compatible message) to a stream


Send

public boolean Send(java.lang.String mailserver,
                    boolean enque)
             throws java.lang.Exception
Sends the message. Mail Servers is a string with one or more hostnames separated by a semicolon. A username and password can also be provided for each server in the format username:password@myhost.mydoman.com.

Throws:
java.lang.Exception

Send

public boolean Send(java.lang.String mailserver)
             throws java.lang.Exception
Throws:
java.lang.Exception

SendToNewsGroup

public void SendToNewsGroup(java.lang.String servername,
                            java.lang.String newsgroups)
Sends the message to NewsGroups(separated by a ",") using the NNTP server specified


VerifyKeys

public boolean VerifyKeys(java.lang.String key)
Returns True if ALL the supplied keys where found in the local keyring.


About

public java.lang.String About()
Some useful information


getAttachments

public Attachments getAttachments()
Returns the Attachments collection


getBody

public java.lang.String getBody()
Returns the message's body


setBody

public void setBody(java.lang.String body)

getBodyText

public java.lang.String getBodyText()

setCharset

public void setCharset(java.lang.String charset)
The charset to the message. the default is "US-ASCII".


setContentTransferEncoding

public void setContentTransferEncoding(java.lang.String cod)
Specifies the content transfer encoding. the defult is "Quoted-Printable".


setContentType

public void setContentType(java.lang.String con)

getContentType

public java.lang.String getContentType()
Returns the body's content-type


getDate

public java.lang.String getDate()
Returns the Date Time when the message was sent.


setDate

public void setDate(java.util.Date d)

setDeferedDelivery

public void setDeferedDelivery(java.util.Date d)
Sets deferred delivery of the messages. if the mail server supports it the message won't be delivered until this date and time.


setEncoding

public void setEncoding(java.lang.String en)
This can be used to changed the default attachment encoding from base64. Valid options are "base64" or "quoted-printable"


setEncryptAttachments

public void setEncryptAttachments(boolean ea)
Set to TRUE all attachments will be encrypted too if encryption is enabled. the default is TRUE.


getErrorCode

public int getErrorCode()
Contains the error code if message.slient is set to TRUE


getErrorMessage

public java.lang.String getErrorMessage()
Contains the error message if message.slient is set to TRUE


getErrorSource

public java.lang.String getErrorSource()
Contains the error source if message.slient is set to TRUE.


setFrom

public void setFrom(java.lang.String f)

getFrom

public java.lang.String getFrom()
The sender's e-mail address


setFromName

public void setFromName(java.lang.String f)

getFromName

public java.lang.String getFromName()

getHeaders

public Headers getHeaders()
Returns the header's object.


setHTMLBody

public void setHTMLBody(java.lang.String h)

getHTMLBody

public java.lang.String getHTMLBody()

setISOEncodeHeaders

public void setISOEncodeHeaders(boolean b)
Encodes header strings according to is-8859-1 character sets. The default is true.


getLog

public java.lang.String getLog()

setLogging

public void setLogging(boolean b)

getMailData

public java.lang.String getMailData()
The raw maildata as the e-mail will look like when it is delivered.


setMailDomain

public void setMailDomain(java.lang.String md)

getMailDomain

public java.lang.String getMailDomain()

setMailServerPassword

public void setMailServerPassword(java.lang.String mp)
Used to specify the password for SMTP server authentication if the mail server requires a user to login.


setMailServerName

public void setMailServerName(java.lang.String user)

setMimeVersion

public void setMimeVersion(java.lang.String v)
Specifies the mime version. the default is "1.0"


getMimeVersion

public java.lang.String getMimeVersion()

setMsPickupdirectory

public void setMsPickupdirectory(java.lang.String p)
The path to the pickup directory of MS SMTP server. if you run MS windows 2000, JMAIL autodeted the path from registry setttings.


setPGPEncrypt

public void setPGPEncrypt(boolean b)
Set to TRUE, the e-mail will be encrypted when the message is sent. using PGP


setPGPPassphrase

public void setPGPPassphrase(boolean b)
The PGP passphrase used when signing


setPGPSign

public void setPGPSign(boolean b)
Set to TRUE, the e-mail will be signed when the message is sent, using PGP.


setPGPSignkey

public void setPGPSignkey(java.lang.String key)
An e-mail address or a PGP keu id identifying the key to be used for signing


setPriority

public void setPriority(int p)
returns the message's priority. 3 is normal priority.


getPriority

public int getPriority()

getRecipients

public Recipients getRecipients()
Returns the recipient's collection


getRecipientsString

public java.lang.String getRecipientsString()
Readonly property of all recipients of this message


setReplyTo

public void setReplyTo(java.lang.String e)
Specifies an optional reply address


getReplyTo

public java.lang.String getReplyTo()

setReturnReceipt

public void setReturnReceipt(boolean b)
Specifies whether or not the sender requires a return receipt. The default value of the property is false.


setSilent

public void setSilent(boolean s)
Set to True , JMAIL will not throw exceptions. Intead Message.send will return True or False depending on the success of the operation.


getSilent

public boolean getSilent()

setSimpleLayout

public void setSimpleLayout(boolean f)
Set to TRUE to reduce the number of the headers JMAil produces.


getSize

public int getSize()
Returns the total size of the message in bytes


getSubject

public java.lang.String getSubject()

setSubject

public void setSubject(java.lang.String sub)

getText

public java.lang.String getText()
Return entire message source


setPopelining

public void setPopelining(boolean b)
Override if JMail should use pipelining on a server that supports it


getVersion

public java.lang.String getVersion()

PGPDecode

public java.lang.Object PGPDecode(boolean decodebody,
                                  boolean decodeattachments)
This method will decode the contents of the message object using PGP , It will decrypt the contents and verify and signatures. A passphrase must be specified for decryption. The two parameters allow for only decoding parts of a message. Set decodebody to True to decrypt / verify the text parts of the message (BODY and HTMLBODY). set decodeAttachments to True to decrypt/verify the attachments of the message. The return values is an PGPGDecodeResults object, holding the results of the operation. PGP errors signature verification status and other results for all decodes parts of the message are reported through this object.


setEnableCharsetTranslation

public void setEnableCharsetTranslation(boolean en)
Set to TRUE , which is the default. JMail will convert the text given in the body or HTMLBOdy properties ti charset specified in the property charset if needed. This is not desired if the text is already encoded. If you for instance put utf-8 encoded text into the BODY, and therefore set the charset ti "UTF-8". you should set this property to FALSE.