Spaces:
Build error
Build error
Update app.py
Browse files236 unmodified lines237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293241294295296297325 unmodified lines623624625573626627628629630578631632633634635636637638639640641642643236 unmodified lines # summarized_response = summarize_document(query_response) return query_response
#mailjet APIdef send_email_with_attachment_mailjet(recipient_email, subject, body, attachment_path): from mailjet_rest import Client import os import base64 # Replace these with your Mailjet API credentials api_key = '9ce0aa1f8eb21d9e2ed2433a5702185b' api_secret = '434e366db9b8c421eef99f6f92129fad' # Initialize the Mailjet client mailjet = Client(auth=(api_key, api_secret), version='v3.1') # Define the email details with an attachment data = { 'Messages': [ { "From": { "Email": "lakshmi.vairamani@redmindtechnologies.com", "Name": "Redmind Technologies" }, "To": [ { "Email": "recipient_email", "Name": "Lakshmi" } ], "Subject": subject, "TextPart": body, "CustomID": "AppGettingStartedTest", "Attachments": [ { "ContentType": "image/png", # Replace with the correct MIME type of your image "Filename": "your_image_name.png", # Name of the image as it will appear in the email "Base64Content": attachment_path # Base64-encoded image content } ] } ] } # Send the email result = mailjet.send.create(data=data) print(result) # Check if the email was sent successfully if result.status_code == 200: print("Email sent successfully with attachment!") else: print(f"Failed to send email. Status code: {result.status_code}") print(result.json())
#async #smtp libdef send_email_with_attachment(recipient_email, subject, body, attachment_path): try: from fastapi import FastAPI325 unmodified lines # email send if len(user_email) > 0: # Send email with the chart image attached send_email_with_attachment( send_email_with_attachment_mailjet( recipient_email=user_email, subject="Warehouse Inventory Report", body=response.get("output", "").split(":")[0], # attachment_path=chart_path attachment_path=os.getenv("IMAGE_PATH") attachment_path=img_str) ) # Send email with the chart image attached """send_email_with_attachment( recipient_email=user_email, subject="Warehouse Inventory Report", body=response.get("output", "").split(":")[0], # attachment_path=chart_path attachment_path=os.getenv("IMAGE_PATH") )"""
if "send email to" in user_question: try:app.py+64-3