I am building a container with python script that sends an email using outlook. I am having trouble adding win32com to my container in the build process. It gives the error No module named 'win32com'. Can someone please help I can't find a solution online. Here's my code:
email.py
import win32com.client as win32
# import json
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = 'bilalhussain.v1@gmail.com'
mail.Subject = 'Testing Email Through Outlook'
mail.Body = 'This shouldnot have taken this long'
mail.HTMLBody = '<h2>Hello World</h2>' #this field is optional
# To attach a file to the email (optional):
attachment = "find.json"
mail.Attachments.Add(attachment)
mail.Send()
requirements.txt
certifi==2020.12.5
click==7.1.2
fastapi==0.63.0
h11==0.11.0
starlette==0.13.6
uvicorn==0.13.3
pywin32==304
win32-setctime==1.0.3
win32com
pypiwin32
Dockerfile
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7
ADD find.json .
ADD email.py .
COPY requirements.txt .
RUN pip --no-cache-dir install -r requirements.txt