python - Python通过win32com向Outlook任务添加超链接
问题描述
我想在通过 win32com 创建的任务正文中创建一个超链接。
到目前为止,这是我的代码:
outlook = win32com.client.Dispatch("Outlook.Application")
outlook_task_item = 3
recipient = "my_email@site.com"
task = outlook.CreateItem(outlook_task_item)
task.Subject = "hello world"
task.Body = "please update the file here"
task.DueDate = dt.datetime.today()
task.ReminderTime = dt.datetime.today()
task.ReminderSet = True
task.Save()
我试图设置属性task.HTMLBody
,但出现错误:
AttributeError: Property 'CreateItem.HTMLBody' can not be set.
我也试过
task.Body = "Here is the <a href='http://www.python.org'>link</a> I need"
但我没有得到正确的超链接。
但是,如果我在 Outlook 中创建任务前端,我可以添加超链接。
解决方案
你也可以试试:
task.HTMLBody = "Here is the <a href='http://www.python.org'>link</a> I need"
这会将“task.Body”中的数据覆盖为“task.HTMLBody”中提供的 HTML 格式
所以无论是最后一个(正文或 HTMLBody)都将被视为邮件的正文。
推荐阅读
- laravel - Laravel FakeID 问题缺少路由所需的参数
- python - 如何从输出中删除最后一个逗号
- r - 在R中附加来自多个Excel文件的多个工作表
- dart - 无法在 dart 中声明二维列表并向其输入元素
- python - 如何根据 tkinter 应用程序中的用户输入更改标签?
- python - 如何从 sympy 方程中提取多项式和非多项式部分?
- python - 如何使用 3 个函数调用一个类?
- aslr - 如何为我的 wpf .net 核心应用程序启用 DEP 和 ASLR 标志?
- android - 获取要在片段中显示的 ListView (Kotlin)
- laravel-8 - 此路由不支持 GET 方法。支持的方法:POST。在 laravel8