Running python to send email in Server Error. Works fine in Desktop!
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi,
How can I get this working on server? I am getting an error when running on the server.
my simple script -
from ayx import Alteryx
import email
from win32com.client import Dispatch
import sys
def SendSummary():
outlook = Dispatch("Outlook.Application")
mail = outlook.CreateItem(0)
mail.To = "email@outlook.com";
mail.Subject = "test";
mail.Body = "test"
mail.Send()
SendSummary()
the server outputs this error - not sure if its because the server doesnt have outlook or something..
--------------------------------------------------------------------------- com_error Traceback (most recent call last) d:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\site-packages\win32com\client\dynamic.py in _GetGoodDispatch(IDispatch, clsctx) 88 try: ---> 89 IDispatch = pythoncom.connect(IDispatch) 90 except pythoncom.ole_error: com_error: (-2147221005, 'Invalid class string', None, None) During handling of the above exception, another exception occurred: com_error Traceback (most recent call last) <ipython-input-1-50feb86ac5e5> in <module> 15 16 ---> 17 SendSummary() 18 <ipython-input-1-50feb86ac5e5> in SendSummary() 7 def SendSummary(): 8 #outlook = None ----> 9 outlook = Dispatch("Outlook.Application") 10 mail = outlook.CreateItem(0) 11 mail.To = "email@outlook.com"; d:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\site-packages\win32com\client\__init__.py in Dispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, clsctx) 93 """ 94 assert UnicodeToString is None, "this is deprecated and will go away" ---> 95 dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) 96 return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx) 97 d:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\site-packages\win32com\client\dynamic.py in _GetGoodDispatchAndUserName(IDispatch, userName, clsctx) 112 else: 113 userName = str(userName) --> 114 return (_GetGoodDispatch(IDispatch, clsctx), userName) 115 116 def _GetDescInvokeType(entry, invoke_type): d:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\site-packages\win32com\client\dynamic.py in _GetGoodDispatch(IDispatch, clsctx) 89 IDispatch = pythoncom.connect(IDispatch) 90 except pythoncom.ole_error: ---> 91 IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) 92 else: 93 # may already be a wrapped class. com_error: (-2147221005, 'Invalid class string', None, None) (Tool Id: 5
- Labels:
- Server
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I'm not a python expert, but it reads as if your script calls the Outlook application, which seems that your server does not have installed, which is typical on a server environment.
I'd suggest using the Email tool or set up an event based email (Workflow Config > Events).
