File size: 21,759 Bytes
9a77024
 
 
 
 
 
 
 
f74bbcc
 
 
9a77024
 
 
 
 
 
 
 
 
 
87b9fb5
ea7b72f
 
 
9a77024
ea7b72f
9a77024
ea7b72f
9a77024
ea7b72f
9a77024
 
ea7b72f
 
 
9a77024
ea7b72f
 
9a77024
87b9fb5
9e040fd
9a77024
 
 
1e46376
 
9a77024
 
 
87b9fb5
 
ea7b72f
 
 
9a77024
ea7b72f
9a77024
ea7b72f
9a77024
 
 
ea7b72f
 
 
9a77024
ea7b72f
 
9a77024
87b9fb5
9e040fd
9a77024
 
 
1e46376
 
9a77024
 
 
ea7b72f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9e040fd
ea7b72f
 
 
 
 
1e46376
 
9a77024
 
 
 
 
 
04e66db
9a77024
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
import streamlit as st
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
import requests
import base64
import os



# Encode the image to Base64
def get_base64_image(image_path):
    with open(image_path, "rb") as image_file:
        return base64.b64encode(image_file.read()).decode()
    


# Define your Slack email addresses and webhook URLs
Slack_email_addresses = {
    'Rahul Mandowara': 'aaaankma7mqecgi5ckgiutv3ga@gofynd.slack.com',
    'Abhimanyu':'aaaanm6gie6scddpk5pycnwwma@gofynd.slack.com',
    'VS': 'aaaaneedladlp3nszpmwwulkay@gofynd.slack.com',
    'ninadmandavkar': 'aaaanfcp5znlb2etchdfewwr3y@gofynd.slack.com',
    'Priyanshi Nahata': 'aaaandms5io6pfh5qawofrdplm@gofynd.slack.com',
    'kiran jadhav': 'aaaangzileg6adyfyz6y7siqme@gofynd.slack.com',
    'Bhavin Parmar': 'aaaannkdegaoe6g3vppkj26ft4@gofynd.slack.com',
    'RJ': 'aaaanf4e6nhjaryx7ba475qp2e@gofynd.slack.com',
    'Roshani Mohan': 'aaaanhjh5f2cihhkybe4k7bdre@gofynd.slack.com',
    'omkarsp': 'aaaanlsvaa7liwu3zgp42artb4@gofynd.slack.com',
    'Abhilash Sawant': 'aaaanp57acudcxnhlgmoonpsri@gofynd.slack.com',
    'Hemant Yadav': 'aaaanz2tp3lxatl4uadyc5h24e@gofynd.slack.com',
    'SandeeP Salunkhe': 'aaaanjukkjprfide3ofd6prno4@gofynd.slack.com',
    'Sid': 'aaaaneehkkyokdx5ydr5ifktui@gofynd.slack.com',
    'chetanpatole': 'aaaanptkf3sbppf5jlrlwlzmme@gofynd.slack.com',
    'Shweta Kanungo': 'aaaannsfn3qehkb4cgfqi7oqbe@gofynd.slack.com',
    'chandnichaurasia': 'aaaantvq257inlgipy6n3n4oyu@gofynd.slack.com',
    'Rasika': 'aaaanjz7aqzgmgvbq2j2erk2xi@gofynd.slack.com',
    'Bhushan Khapare': 'aaaanhompmuol3cupdtcbhyzaa@gofynd.slack.com',
    'Vaibhavi':'aaaanimf7vltovi7cs5gwknmre@gofynd.slack.com',
    'Khushbu':'aaaaojhzcatkkpx7ok2424kvvq@gofynd.slack.com',
    'daily-alerts-for-unsubscribed-companies': 'daily-alerts-for-unsu-aaaanufptnpzgjtmknapgi45oq@gofynd.slack.com',
    'finance_team_internal': 'finance_team_internal-aaaabrz6gd5km3hjwxs7saxa4a@gofynd.slack.com',
    'valyx-fynd-poc': 'valyx-fynd-poc-aaaamwv2kpahjf3krqa752pate@gofynd.slack.com',
    'valyx_auto_invoices': 'valyx_auto_invoices-aaaanykb7mbnlhtajda4slllia@gofynd.slack.com',
    'recon-check': 'recon-check-aaaan32uofkccdehnmkymfp5qu@gofynd.slack.com'
}

gmail_addresses = {
    'Rahul Mandowara': 'rahulmandowara@gofynd.com',
    'Abhimanyu':'abhimanyumallik@gofynd.com',
    'VS': 'vikysangoi@gofynd.com',
    'ninadmandavkar': 'ninadmandavkar@gofynd.com',
    'omkarsp': 'omkarsp@gofynd.com',
    'Priyanshi Nahata': 'priyanshinahata@gofynd.com',
    'kiran jadhav': 'kiranjadhav@gofynd.com',
    'Bhavin Parmar': 'bhavinparmar@gofynd.com',
    'RJ': 'rasikajadhav@gofynd.com',
    'Roshani Mohan': 'roshanimohan@gofynd.com',
    'Abhilash Sawant': 'abhilashsawant@gofynd.com',
    'Hemant Yadav': 'hemantyadav@gofynd.com',
    'SandeeP Salunkhe': 'sandeepsalunkhe@gofynd.com',
    'Sid': 'siddheshmayekar@gofynd.com',
    'chetanpatole': 'chetanpatole@gofynd.com',
    'Shweta Kanungo': 'shwetakanungo@gofynd.com',
    'chandnichaurasia': 'chandnichaurasia@gofynd.com',
    'Rasika': 'rasikasalunkhe@gofynd.com',
    'Bhushan Khapare': 'bhushankhapare@gofynd.com',
    'Vaibhavi': 'vaibhavidambe@gofynd.com',
    'Khushbu': 'khushbuchaurasia@gofynd.com',
    'daily-alerts-for-unsubscribed-companies': 'daily-alerts-for-unsu-aaaanufptnpzgjtmknapgi45oq@gofynd.slack.com',
    'finance_team_internal': 'finance_team_internal-aaaabrz6gd5km3hjwxs7saxa4a@gofynd.slack.com',
    'valyx-fynd-poc': 'valyx-fynd-poc-aaaamwv2kpahjf3krqa752pate@gofynd.slack.com',
    'valyx_auto_invoices': 'valyx_auto_invoices-aaaanykb7mbnlhtajda4slllia@gofynd.slack.com',
    'recon-check': 'recon-check-aaaan32uofkccdehnmkymfp5qu@gofynd.slack.com'
}

Webhook_urls = {
    'Rahul Mandowara': 'https://hooks.slack.com/services/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',
    'Abhimanyu':'https://hooks.slack.com/services/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',
    'VS': 'https://hooks.slack.com/services/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',
    'ninadmandavkar': 'https://hooks.slack.com/services/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',
    'Priyanshi Nahata': 'https://hooks.slack.com/services/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',
    'kiran jadhav': 'https://hooks.slack.com/services/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',
    'Bhavin Parmar': 'https://hooks.slack.com/services/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',
    'RJ': 'https://hooks.slack.com/services/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',
    'Roshani Mohan': 'https://hooks.slack.com/services/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',
    'omkarsp': 'https://hooks.slack.com/services/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',
    'Abhilash Sawant': 'https://hooks.slack.com/services/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',
    'Hemant Yadav': 'https://hooks.slack.com/services/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',
    'SandeeP Salunkhe': 'https://hooks.slack.com/services/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',
    'Sid': 'https://hooks.slack.com/services/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',
    'chetanpatole': 'https://hooks.slack.com/services/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',
    'Shweta Kanungo': 'https://hooks.slack.com/services/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',
    'chandnichaurasia': 'https://hooks.slack.com/services/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',
    'Rasika': 'https://hooks.slack.com/services/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',
    'Khushbu': 'https://hooks.slack.com/services/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',
    'Bhushan Khapare': 'https://hooks.slack.com/services/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',
    'Vaibhavi': 'https://hooks.slack.com/services/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',
    'daily-alerts-for-unsubscribed-companies': 'https://hooks.slack.com/services/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',
    'finance_team_internal': 'https://hooks.slack.com/services/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',
    'valyx-fynd-poc': 'https://hooks.slack.com/services/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',
    'valyx_auto_invoices': 'https://hooks.slack.com/services/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',
    'recon-check': 'https://hooks.slack.com/services/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'
}

# Define your email server details
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'ninadmandavkar@gofynd.com'
EMAIL_HOST_PASSWORD = 'etdv kmvs qbsi zose'

def send_message_via_email(message, email_address, files, subject=None, body=None):
    try:
        # Set up the server
        server = smtplib.SMTP(EMAIL_HOST, EMAIL_PORT)
        server.starttls()
        server.login(EMAIL_HOST_USER, EMAIL_HOST_PASSWORD)

        # Create the email
        msg = MIMEMultipart()
        msg['From'] = EMAIL_HOST_USER
        msg['To'] = email_address
        msg['Subject'] = subject if subject else "🚨 Alerter"

        # Attach the message body
        msg.attach(MIMEText(body if body else message, 'plain'))

        # Attach each file if provided
        if files:
            for uploaded_file in files:
                part = MIMEBase('application', 'octet-stream')
                part.set_payload(uploaded_file.read())
                encoders.encode_base64(part)
                part.add_header('Content-Disposition', f'attachment; filename={uploaded_file.name}')
                msg.attach(part)

        # Send the email
        server.sendmail(EMAIL_HOST_USER, email_address, msg.as_string())
        server.quit()
        return True, "Message sent successfully"
    except Exception as e:
        return False, str(e)

def send_message_via_webhook(message, webhook_url):
    try:
        payload = {
            "text": message
        }
        response = requests.post(webhook_url, json=payload)
        response.raise_for_status()
        return True, "Message sent successfully"
    except requests.exceptions.RequestException as e:
        return False, str(e)

def main():

    # Path to your image
    image_path = "Designer (1).png"
    base64_image = get_base64_image(image_path)

    # Define the CSS for setting the background image
    # background_image_css = f"""
    # <style>
    #     .stApp {{
    #         background-image: url(data:image/png;base64,{base64_image});
    #         background-size: 100%;
    #         background-repeat: no-repeat;
    #         background-attachment: fixed;
    #         background-position: center;
    #         height: 100vh; /* Make sure the background covers the full viewport height */
            
    #     }}
    # </style>
    # """

    # # Apply the CSS to the Streamlit app
    # st.markdown(background_image_css, unsafe_allow_html=True)


    
    html_subject = """
<html>
<head>
<style>
    .button {
        display: inline-block;
        padding: 10px 20px;
        border-radius: 12px;
        background: linear-gradient(to bottom, #f8f9fa, #e0e0e0);
        box-shadow: 
            0 6px 12px rgba(0, 0, 0, 0.3), 
            0 8px 16px rgba(0, 0, 0, 0.2), 
            inset 0 -2px 4px rgba(255, 255, 255, 0.6);
        text-align: center;
        position: relative;
        transform: translateY(4px);
        transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
        cursor: pointer;
        user-select: none;
    }
    .button:hover {
        box-shadow: 
            0 8px 16px rgba(0, 0, 0, 0.3), 
            0 12px 24px rgba(0, 0, 0, 0.2);
        transform: translateY(2px);
    }
    .button:active {
        box-shadow: 
            0 4px 8px rgba(0, 0, 0, 0.3), 
            0 6px 12px rgba(0, 0, 0, 0.2);
        transform: translateY(0);
    }
</style>
</head>
<body>
    <div class="button">
        <h3 style="
            font-size: 20px;
            color: #ffffff;
            background-image: linear-gradient(to right, #800000, #ff0000, #ffdab9);
            background-clip: text;
            -webkit-background-clip: text;
            text-fill-color: transparent;
            -webkit-text-fill-color: transparent;
            margin: 0;
            text-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
        ">Write a Slack message</h3>
    </div>
</body>
</html>
"""



    st.markdown(html_subject, unsafe_allow_html=True)
    message = st.text_area("", "")
    

    # File uploader widget with a unique key
    html_subject = """
    <html>
    <head>
    <style>
        .button {
            display: inline-block;
            padding: 10px 20px;
            border-radius: 12px;
            background: linear-gradient(to bottom, #f8f9fa, #e0e0e0);
            box-shadow: 
                0 6px 12px rgba(0, 0, 0, 0.3), 
                0 8px 16px rgba(0, 0, 0, 0.2), 
                inset 0 -2px 4px rgba(255, 255, 255, 0.6);
            text-align: center;
            position: relative;
            transform: translateY(4px);
            transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
            cursor: pointer;
            user-select: none;
        }
        .button:hover {
            box-shadow: 
                0 8px 16px rgba(0, 0, 0, 0.3), 
                0 12px 24px rgba(0, 0, 0, 0.2);
            transform: translateY(2px);
        }
        .button:active {
            box-shadow: 
                0 4px 8px rgba(0, 0, 0, 0.3), 
                0 6px 12px rgba(0, 0, 0, 0.2);
            transform: translateY(0);
        }
    </style>
    </head>
    <body>
        <div class="button">
            <h3 style="
                font-size: 20px;
                color: #ffffff;
                background-image: linear-gradient(to right, #800000, #ff0000, #ffdab9);
                background-clip: text;
                -webkit-background-clip: text;
                text-fill-color: transparent;
                -webkit-text-fill-color: transparent;
                margin: 0;
                text-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
            ">Upload documents</h3>
        </div>
    </body>
    </html>
    """


    st.markdown(html_subject, unsafe_allow_html=True)
    uploaded_file = st.file_uploader("", type=["pdf", "docx", "png", "jpeg", "xlsx", "csv", "json"], key="file_uploader", accept_multiple_files= True)

    # Dropdown for channels/members
    options = list(Slack_email_addresses.keys())
    html_subject = """
    <html>
    <head>
    <style>
        .button {
            display: inline-block;
            padding: 10px 20px;
            border-radius: 12px;
            background: linear-gradient(to bottom, #f8f9fa, #e0e0e0);
            box-shadow: 
                0 6px 12px rgba(0, 0, 0, 0.3), 
                0 8px 16px rgba(0, 0, 0, 0.2), 
                inset 0 -2px 4px rgba(255, 255, 255, 0.6);
            text-align: center;
            position: relative;
            transform: translateY(4px);
            transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
            cursor: pointer;
            user-select: none;
        }
        .button:hover {
            box-shadow: 
                0 8px 16px rgba(0, 0, 0, 0.3), 
                0 12px 24px rgba(0, 0, 0, 0.2);
            transform: translateY(2px);
        }
        .button:active {
            box-shadow: 
                0 4px 8px rgba(0, 0, 0, 0.3), 
                0 6px 12px rgba(0, 0, 0, 0.2);
            transform: translateY(0);
        }
    </style>
    </head>
    <body>
        <div class="button">
            <h3 style="
                font-size: 20px;
                color: #ffffff;
                background-image: linear-gradient(to right, #800000, #ff0000, #ffdab9);
                background-clip: text;
                -webkit-background-clip: text;
                text-fill-color: transparent;
                -webkit-text-fill-color: transparent;
                margin: 0;
                text-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
            ">Select channels/members</h3>
        </div>
    </body>
    </html>
    """


    st.markdown(html_subject, unsafe_allow_html=True)
    selection = st.multiselect("", options)

    html_subject = """
    <html>
    <head>
    <style>
        .button {
            display: inline-block;
            padding: 10px 20px;
            border-radius: 12px;
            background: linear-gradient(to bottom, #f8f9fa, #e0e0e0);
            box-shadow: 
                0 6px 12px rgba(0, 0, 0, 0.3), 
                0 8px 16px rgba(0, 0, 0, 0.2), 
                inset 0 -2px 4px rgba(255, 255, 255, 0.6);
            text-align: center;
            position: relative;
            transform: translateY(4px);
            transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
            cursor: pointer;
            user-select: none;
        }
        .button:hover {
            box-shadow: 
                0 8px 16px rgba(0, 0, 0, 0.3), 
                0 12px 24px rgba(0, 0, 0, 0.2);
            transform: translateY(2px);
        }
        .button:active {
            box-shadow: 
                0 4px 8px rgba(0, 0, 0, 0.3), 
                0 6px 12px rgba(0, 0, 0, 0.2);
            transform: translateY(0);
        }
    </style>
    </head>
    <body>
        <div class="button">
            <h3 style="
                font-size: 20px;
                color: #ffffff;
                background-image: linear-gradient(to right, #800000, #ff0000, #ffdab9);
                background-clip: text;
                -webkit-background-clip: text;
                text-fill-color: transparent;
                -webkit-text-fill-color: transparent;
                margin: 0;
                text-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
            ">Enter the subject(optional)</h3>
        </div>
    </body>
    </html>
    """


    st.markdown(html_subject, unsafe_allow_html=True)
    subject = st.text_input("", "",key ="subject_text_input")



    html_subject = """
    <html>
    <head>
    <style>
        .button {
            display: inline-block;
            padding: 10px 20px;
            border-radius: 12px;
            background: linear-gradient(to bottom, #f8f9fa, #e0e0e0);
            box-shadow: 
                0 6px 12px rgba(0, 0, 0, 0.3), 
                0 8px 16px rgba(0, 0, 0, 0.2), 
                inset 0 -2px 4px rgba(255, 255, 255, 0.6);
            text-align: center;
            position: relative;
            transform: translateY(4px);
            transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
            cursor: pointer;
            user-select: none;
        }
        .button:hover {
            box-shadow: 
                0 8px 16px rgba(0, 0, 0, 0.3), 
                0 12px 24px rgba(0, 0, 0, 0.2);
            transform: translateY(2px);
        }
        .button:active {
            box-shadow: 
                0 4px 8px rgba(0, 0, 0, 0.3), 
                0 6px 12px rgba(0, 0, 0, 0.2);
            transform: translateY(0);
        }
    </style>
    </head>
    <body>
        <div class="button">
            <h3 style="
                font-size: 20px;
                color: #ffffff;
                background-image: linear-gradient(to right, #800000, #ff0000, #ffdab9);
                background-clip: text;
                -webkit-background-clip: text;
                text-fill-color: transparent;
                -webkit-text-fill-color: transparent;
                margin: 0;
                text-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
            ">Enter the body (optional)</h3>
        </div>
    </body>
    </html>
    """


    st.markdown(html_subject, unsafe_allow_html=True)
    body = st.text_area("", "", key="body_text_area")
    

    button_styles = """
                    <style>
                    div.stButton > button {
                        color: #ffffff; /* Text color */
                        font-size: 30px;
                        background-image: linear-gradient(to right, #800000, #ff0000); /* Maroon to light red gradient */
                        border: none;
                        padding: 10px 20px;
                        cursor: pointer;
                        border-radius: 15px;
                        display: inline-block;
                        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 8px 15px rgba(0, 0, 0, 0.1); /* Box shadow */
                        transition: all 0.3s ease; /* Smooth transition on hover */
                    }
                    div.stButton > button:hover {
                        background-color: #00ff00; /* Hover background color */
                        color: #ff0000; /* Hover text color */
                        box-shadow: 0 6px 10px rgba(0, 0, 0, 0.2), 0 12px 20px rgba(0, 0, 0, 0.2); /* Box shadow on hover */
                    }
                    </style>
                """
    st.markdown(button_styles, unsafe_allow_html=True)

    col1, col2 = st.columns([0.125, 0.5])
    with col1:
        if st.button("Send to Slack"):
            if not message and not uploaded_file:
                st.error("Please enter a message or upload a document before sending.")
                return

            if not selection:
                st.error("Please select at least one channel or member")
                return 

            for item in selection:
                if uploaded_file:
                    # Send the document via email
                    email_address = Slack_email_addresses.get(item)
                    if email_address:
                        success, response_message = send_message_via_email(message, email_address, uploaded_file, subject, body)
                        # if success:
                        #     st.success(f"Document sent to {item} via email.")
                        # else:
                        #     st.error(f"Failed to send document to {item}: {response_message}")
                    else:
                        st.error(f"No email address found for {item}.")
                elif message:
                    # Send the message via Slack webhook
                    webhook_url = Webhook_urls.get(item)
                    if webhook_url:
                        success, response_message = send_message_via_webhook(message, webhook_url)
                        # if success:
                        #     st.success(f"Message sent to {item} via Slack webhook.")
                        # else:
                        #     st.error(f"Failed to send message to {item}: {response_message}")
                    else:
                        st.error(f"No webhook URL found for {item}.")

    with col2:
        if st.button("Send to Gmail"):
            if not message and not uploaded_file:
                st.error("Please enter a message or upload a document before sending.")
                return

            if not selection:
                st.error("Please select at least one channel or member")
                return

            for item in selection:
                email_address = gmail_addresses.get(item)
                if email_address:
                    success, response_message = send_message_via_email(message, email_address, uploaded_file, subject, body)
                    # if success:
                    #     st.success(f"Message sent to {item} via Gmail.")
                    # else:
                    #     st.error(f"Failed to send message to {item}: {response_message}")
                else:
                    st.error(f"No Gmail address found for {item}.")

if __name__ == "__main__":
    main()