首页 > 解决方案 > 如何从 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)'''

标签: pythonflaskpywin32win32com

解决方案


    uploaded_files = rq.files.getlist("filesattach")
    
    for i in uploaded_files:
        file = os.path.realpath(str(i.filename))
        msg.attachments.Add(file)

推荐阅读