package infra.services
import play.api.mvc._
import play.api._
import play.api.i18n._
import com.typesafe.plugin._
import play.api.Play.current

case class SendMail(notifyTypeForMessage: Long, fromAddress: String, partId: Long, designChangeId: Long, notifyTypeForLink: Long, state: Long) {
  def sendMail(toAddress:String) = {
    var mail = use[com.typesafe.plugin.MailerPlugin].email
    mail.addFrom(this.fromAddress)
    mail.setSubject(Messages("mail.message1" + notifyTypeForMessage))
    mail.addRecipient(toAddress)
    if(partId != 0) {
    	mail.sendHtml("<html>" + Messages("mail.message1" + notifyTypeForMessage) +
    		"<br /><a href=\"http://" + Messages("apserver.name") + ":9000/notifylist?page=0&partId=" + this.partId + "&notifyType=" + notifyTypeForLink + "&state=" + this.state + "\" " + ">" + Messages("mail.message2") + "</a></html>")
    } else {
    	mail.sendHtml("<html>" + Messages("mail.message1" + notifyTypeForMessage) +
    		"<br /><a href=\"http://" + Messages("apserver.name") + ":9000/designChangeNotifylist?page=0&designChangeId=" + this.designChangeId + "&notifyType=" + notifyTypeForLink + "&state=" + this.state + "\" " + ">" + Messages("mail.message2") + "</a></html>")      
    }
  }
}
