com.objectplanet.survey.plugin.api
Class Email

java.lang.Object
  extended by com.objectplanet.survey.plugin.api.Email

public class Email
extends java.lang.Object

Object that represents an email. Example of email creation:

        try {
                Email email = new Email(fromName, fromEmail,
                                        toEmail,subject, message,
                                        type);
        } catch (Throwable e) {
                //Do something
        }
  

Author:
Ina Skåre
Created:
16. September 2004

Constructor Summary
Email(java.lang.String fromName, java.lang.String fromEmail, java.lang.String toEmail, java.lang.String subject, java.lang.String message, java.lang.String type)
          Constructor for the email to one recipient
 
Method Summary
 void addAttachment(java.lang.String filename, java.lang.String file)
          Add attachment to the email
 void addRecipient(java.lang.String emailAddress)
          Add a recipient
 void createMessage(java.lang.String fromName, java.lang.String fromEmail, java.lang.String subject, java.lang.String message, java.lang.String type)
          Create an email message
 com.objectplanet.survey.util.Email getEmailObject()
          Gets the save value
 java.lang.String getEmailType()
          Gets the email type
 long getFailedId()
          Get the failed id.
 boolean getSave()
          Gets the save value
 void setEmailType(java.lang.String emailType)
          Set the id of the email if failed
 void setFailedId(long failedId)
          Set the id of the email if failed
 void setSave(boolean saveToFailedEmails)
          Set the save variable
 java.lang.String toLogString()
          Return string object for this email (used for logging)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Email

public Email(java.lang.String fromName,
             java.lang.String fromEmail,
             java.lang.String toEmail,
             java.lang.String subject,
             java.lang.String message,
             java.lang.String type)
      throws EmailCreationException,
             javax.mail.internet.AddressException
Constructor for the email to one recipient

Parameters:
fromName - Who sends the message (name)
fromEmail - Who sends the message(email address)
toEmail - Recipients' email
subject - The subject of the email
message - The body of the message
type - The type of the message (text/plain or text/html)
Throws:
EmailCreationException - Error during email creation
javax.mail.internet.AddressException - Error during recipient creation
Method Detail

createMessage

public void createMessage(java.lang.String fromName,
                          java.lang.String fromEmail,
                          java.lang.String subject,
                          java.lang.String message,
                          java.lang.String type)
                   throws com.objectplanet.survey.util.EmailCreationException
Create an email message

Parameters:
fromName - Who sends the message (name)
fromEmail - Who sends the message(email address)
subject - The subject of the email
message - The body of the message
type - The type of the message body (text/plain or text/html)
Throws:
EmailCreationException - If error
com.objectplanet.survey.util.EmailCreationException

addAttachment

public void addAttachment(java.lang.String filename,
                          java.lang.String file)
                   throws java.io.IOException,
                          javax.mail.MessagingException
Add attachment to the email

Parameters:
filename - Visible file name ("myFile.txt")
file - File path
Throws:
java.io.IOException - IOException
javax.mail.MessagingException - MessagingException

addRecipient

public void addRecipient(java.lang.String emailAddress)
                  throws javax.mail.internet.AddressException
Add a recipient

Parameters:
newRecipient - Recipient to add
Throws:
javax.mail.internet.AddressException - Error during recipient creation

toLogString

public java.lang.String toLogString()
Return string object for this email (used for logging)

Returns:
String presentation of the object

setEmailType

public void setEmailType(java.lang.String emailType)
Set the id of the email if failed

Parameters:
emailType - The new email type (text/plain or text/html)

setFailedId

public void setFailedId(long failedId)
Set the id of the email if failed

Parameters:
failedId - The new id

setSave

public void setSave(boolean saveToFailedEmails)
Set the save variable

Parameters:
saveToFailedEmails - True if the email should be saved to failed mails in case it fails

getFailedId

public long getFailedId()
Get the failed id.

Returns:
The failedId value

getEmailType

public java.lang.String getEmailType()
Gets the email type

Returns:
The type of the mail(Content-Type)

getSave

public boolean getSave()
Gets the save value

Returns:
True if the email should be saved to failed mailes in case it fails

getEmailObject

public com.objectplanet.survey.util.Email getEmailObject()
Gets the save value

Returns:
True if the email should be saved to failed mailes in case it fails

Copyright ? ObjectPlanet Inc. All Rights Reserved.

Built on December 20 2016