python - 如何从 Flask 添加附件到 win32com?
问题描述
嗨,我无法将烧瓶上传附加到 Outlook,
我需要将烧瓶中的上传附加到 Outlook。
谢谢
''' f = rq.files['filesattach']
msg.HTMLBody = str("<br> <br>Hi, the follow data are attached to this email <br>").title() + "\n \n" + "<br> Date Request Sent to Permit Coordinator: " + dateReq + "\n" + "<br>WO #: "+ wo+ " \n" + "<br>Date Needed: " + dateNeed + "\n" +"<br>SR: "+ sr + "\n" + "<br>TCF: " +tcf + "\n" + "<br>Munplicity: "+ mun + "\n" + "<br>Political Sub: " + polSub + "\n" + '<br>Address: '+ address + "\n" + '<br>Cross Street: ' + cross + "\n" + '<br>Description: '+ desc + "\n" + "<br>Permit Type: " + permitType
msg.Subject = "WO " + wo +" "+ permitType+" "+"Permit Form"
msg.Display()
shell.AppActivate("Outlook")
shell.SendKeys("%s", 0)
saved = f.save(secure_filename(f.filename))
return "Message sent"
else:
return render_template(permitForm)'''
解决方案
uploaded_files = rq.files.getlist("filesattach")
for i in uploaded_files:
file = os.path.realpath(str(i.filename))
msg.attachments.Add(file)
推荐阅读
- wso2 - 身份服务器 - 添加服务提供者空白页
- reactjs - 如何在 ReactJS 中链接动作?
- javascript - 可以使用一个模块来通信两个不同的 JavaScript 模块吗?
- javascript - 有没有办法编辑这个小部件在我的网站上的加载方式,以做出响应
- aws-lambda - (InvalidRequestException) 调用 GetQueryResults 时......从 Lambda Python 查询 Athena......无法读取结果
- c++ - 为什么 gcc 和 clang 为函数模板的实例化生成不同的符号名称?
- bash - 是否可以在 Bash 中执行所有命令时打印它们?
- gdb - Intel Pin GDB 运行时开销
- macros - 在 C 中,您可以将具有多个值的宏传递给函数吗
- mysql - mysql date函数和count函数一起使用时出现500错误