chrisaldikaraharja commited on
Commit
634353f
·
verified ·
1 Parent(s): b7bd985

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -32
app.py CHANGED
@@ -19,6 +19,37 @@ st.write(data.head()) # Displaying the first few rows of the dataset
19
  MAILJET_API_KEY = 'f746efdd7af5c96a033ddb90a78a5704'
20
  MAILJET_SECRET_KEY = '5ee6955f792909206669fb10e9910b57'
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  def generate_follow_up_message(patient_name):
23
  try:
24
  # Filter data by patient name
@@ -100,35 +131,4 @@ if patient_name_input:
100
  except Exception as e:
101
  st.error(f"Failed to send email: {e}")
102
  else:
103
- st.warning(follow_up_message)
104
-
105
- # Function to send email using Mailjet
106
- def send_email(recipient_email, follow_up_message):
107
- # Mailjet API endpoint
108
- url = 'https://api.mailjet.com/v3.1/send'
109
-
110
- # Sender email and details
111
- from_email = 'christ10aldika@gmail.com' # Sender email
112
- subject = 'Appointment Reminder'
113
-
114
- # Email payload
115
- payload = {
116
- "Messages": [
117
- {
118
- "From": {"Email": from_email, "Name": "Christ Aldika"}, # Sender name and email
119
- "To": [{"Email": recipient_email, "Name": recipient_email}], # Recipient email
120
- "Subject": subject,
121
- "TextPart": follow_up_message, # Use the generated follow-up message
122
- }
123
- ]
124
- }
125
-
126
- # Send the email request
127
- response = requests.post(url, json=payload, auth=(MAILJET_API_KEY, MAILJET_SECRET_KEY))
128
-
129
- if response.status_code == 200:
130
- print("Email sent successfully via Mailjet!")
131
- print("Response:", response.json())
132
- else:
133
- print(f"Failed to send email. Status Code: {response.status_code}")
134
- print("Response:", response.text)
 
19
  MAILJET_API_KEY = 'f746efdd7af5c96a033ddb90a78a5704'
20
  MAILJET_SECRET_KEY = '5ee6955f792909206669fb10e9910b57'
21
 
22
+ # Function to send email using Mailjet
23
+ def send_email(recipient_email, follow_up_message):
24
+ # Mailjet API endpoint
25
+ url = 'https://api.mailjet.com/v3.1/send'
26
+
27
+ # Sender email and details
28
+ from_email = 'christ10aldika@gmail.com' # Sender email
29
+ subject = 'Appointment Reminder'
30
+
31
+ # Email payload
32
+ payload = {
33
+ "Messages": [
34
+ {
35
+ "From": {"Email": from_email, "Name": "Christ Aldika"}, # Sender name and email
36
+ "To": [{"Email": recipient_email, "Name": recipient_email}], # Recipient email
37
+ "Subject": subject,
38
+ "TextPart": follow_up_message, # Use the generated follow-up message
39
+ }
40
+ ]
41
+ }
42
+
43
+ # Send the email request
44
+ response = requests.post(url, json=payload, auth=(MAILJET_API_KEY, MAILJET_SECRET_KEY))
45
+
46
+ if response.status_code == 200:
47
+ print("Email sent successfully via Mailjet!")
48
+ print("Response:", response.json())
49
+ else:
50
+ print(f"Failed to send email. Status Code: {response.status_code}")
51
+ print("Response:", response.text)
52
+
53
  def generate_follow_up_message(patient_name):
54
  try:
55
  # Filter data by patient name
 
131
  except Exception as e:
132
  st.error(f"Failed to send email: {e}")
133
  else:
134
+ st.warning(follow_up_message)