Skip to content

Commit

Permalink
latest email,
Browse files Browse the repository at this point in the history
latest email
  • Loading branch information
watzausername committed Dec 11, 2018
1 parent 9f6c78d commit fac2c54
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 6 deletions.
9 changes: 9 additions & 0 deletions .idea/libraries/activation_1_1_1.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/libraries/commons_email_1_4.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/libraries/javax_mail_1_5_2.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions cecs343.iml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="javax.mail-1.5.2" level="project" />
<orderEntry type="library" name="commons-email-1.4" level="project" />
<orderEntry type="library" name="activation-1.1.1" level="project" />
</component>
</module>
40 changes: 34 additions & 6 deletions src/Squeal.kt
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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 = "[email protected]"
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("<html><h1>"+ emailMSG+ "</h1></html>")
email.send()

return true;
}catch(ex:Exception){
return false;
}


return emailSent
}

// Change the reminder for this appointment
Expand Down

0 comments on commit fac2c54

Please sign in to comment.