Outlook API connections in st.secrets

Dear friends,
I want to send automatic emails thorough my streamlit app. I am not that much experienced in APIs.
I can simply connect my python with my outlook in my local server (laptop) using:

win32com.client.Dispatch("outlook.application")

But this won’t work if I deploy the app on the cloud. How can I find a sample of outlook credentials in st.secrets?

Thanks in advance

Just to be sure it’s clear: The command you wrote is using an installed Outlook client in a Windows environment to send mail (which is already logged in/authorized). If you want to send email from a cloud environment, you will have to use something entirely different. Yes, you would have the credentials for it in secrets, but it’s not something that command would use.

To use secrets in Streamlit Cloud, you will save your username, password, key, etc like environment variables that you can call in your script.

So if you use the Outlook API to connect and send an email, you would save some outlook_username and outlook_password in your secrets file, then call them through st.secrets to use them with the API.

If you use pyoutlook, here’s the quickstart example:
https://pyoutlook.readthedocs.io/en/latest/quickstart.html

1 Like

Dear mathcatsand,
I am always grateful for your support.
I found this library, but I checked its trust level on this website:
pyOutlook - Python Package Health Analysis | Snyk
I couldn’t be sure to use that. In your opinion, is it a trustworthy library? Did you have experience with that?

As I mentioned in DMs, I can’t vouch for the security of the implementation. I’ve never used it nor dug into its code. I would use Microsoft’s API directly if I were connecting my own account to be certain of security.

1 Like