diff --git a/.idea/libraries/activation_1_1_1.xml b/.idea/libraries/activation_1_1_1.xml new file mode 100644 index 0000000..79e88f2 --- /dev/null +++ b/.idea/libraries/activation_1_1_1.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/commons_email_1_4.xml b/.idea/libraries/commons_email_1_4.xml new file mode 100644 index 0000000..9dd524d --- /dev/null +++ b/.idea/libraries/commons_email_1_4.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/javax_mail_1_5_2.xml b/.idea/libraries/javax_mail_1_5_2.xml new file mode 100644 index 0000000..de8bd30 --- /dev/null +++ b/.idea/libraries/javax_mail_1_5_2.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/cecs343.iml b/cecs343.iml index 973b2cb..1097d3c 100644 --- a/cecs343.iml +++ b/cecs343.iml @@ -17,5 +17,8 @@ + + + \ No newline at end of file diff --git a/src/Squeal.kt b/src/Squeal.kt index 2a50ee2..e9debae 100644 --- a/src/Squeal.kt +++ b/src/Squeal.kt @@ -1,10 +1,22 @@ + +import com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException +import jdk.nashorn.internal.objects.NativeError.setFileName +import javax.activation.DataHandler +import javax.activation.FileDataSource + + +import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeBodyPart +import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeMultipart +import org.apache.commons.mail.DefaultAuthenticator +import org.apache.commons.mail.HtmlEmail +import java.net.URL // We will be using the user's locally installed database for the purposes // of this assignment. The user should already have a MYSQL database // created with the name "scheduler" const val SQL_URL = "jdbc:mysql://localhost:3306/" const val SQLDatabase = "scheduler?useLegacyDatetimeCode=false&serverTimezone=UTC&useSSL=false" -const val SQLUsername = "java" -const val SQLPassword = "coffee" +const val SQLUsername = "root" +const val SQLPassword = "password" // Query that gets the number of entries that match account's username fun checkForExistingUsername(name: String): String { @@ -102,15 +114,31 @@ fun removeAppointment(appID: Int): String { //Returns false for email not sent fun sendEmail(emailAddress: String, appointmentName: String, startDate: String, username: String): Boolean{ - val emailSent = emailAddress == ""//Set to true if email is sent + val emailMSG = " Hello, $username \nYou have a/an $appointmentName @ $startDate "//Message String println(emailMSG) - //TODO actually send message emailMSG and update emailSent - + val senderEmail = "diego@sn.gy" + val password = "#passsword" + val toMail = emailAddress + try{ + val email = HtmlEmail() + email.hostName = "smtp.googlemail.com" + email.setSmtpPort(465) + email.setAuthenticator(DefaultAuthenticator(senderEmail, password)) + email.isSSLOnConnect = true + email.setFrom(senderEmail) + email.addTo(toMail) + email.subject = "You have a new Apointment" + email.setHtmlMsg("

"+ emailMSG+ "

") + email.send() + + return true; + }catch(ex:Exception){ + return false; + } - return emailSent } // Change the reminder for this appointment