英文:
While Outlook is running, my program(win32.client) does not working
问题
以下是已经翻译好的部分:
I made a mail sending program through python and gui.
我通过Python和GUI制作了一个邮件发送程序。
However, my program created with win32.client and outlook do not run at the same time.
然而,使用win32.client和Outlook创建的程序不能同时运行。
Running the code in VScode works fine even if outlook is running.
在VScode中运行代码,即使Outlook正在运行也没有问题。
However, if you run it after making it with pyinstaller -w, an error occurs when outlook is running. If outlook is not running, it will run without problems, but outlook cannot be run.
然而,如果使用pyinstaller -w制作后运行,当Outlook正在运行时会出现错误。如果Outlook未运行,则可以正常运行,但无法启动Outlook。
If I call outlook.application, it seems to be a problem because it is a duplicate call with outlook execution.
如果我调用outlook.application,似乎会出现问题,因为这与Outlook的执行重复。
So I thought about using outlook.mailItem, but it doesn't work properly.
因此,我考虑使用outlook.mailItem,但它无法正常工作。
What could be the problem?
问题可能是什么?
英文:
I made a mail sending program through python and gui.
However, my program created with win32.client and outlook do not run at the same time.
Running the code in VScode works fine even if outlook is running.
However, if you run it after making it with pyinstaller -w, an error occurs when outlook is running. If outlook is not running, it will run without problems, but outlook cannot be run.
All of the below are causing problems.
import win32.client as win32
...
outlook = win32.gencache.EnsureDispatch('Outlook.Application') -- failed
...
#outlook = win32.Dispatch('Outlook.Application') -- failed as well
#outlook = win32.GetActiveObject("Outlook.Application") -- failed
#outlook = win32.GetObject(None, "Outlook.Application") -- didn't expect
#outlook = win32.GetActiveObject("Outlook.Application")
#olmailitem = 0x0
#mail = outlook.CreateItem(olmailitem)
mail = outlook.CreateItem(0)
subject = " "
body =" "
mail.To = to
for path in attachments:
mail.Attachments.Add(path)
mail.Send()
If I call outlook.application, it seems to be a problem because it is a duplicate call with outlook execution.
So I thought about using outlook.mailItem, but it doesn't work properly.
What could be the problem?
答案1
得分: 1
我有:
outlook = win32.Dispatch('outlook.application')
注意 outlook 和 application 的大小写。
英文:
I have:
outlook = win32.Dispatch('outlook.application')
Notice the case on outlook and appplication
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论