Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 以HTML电子邮件发送时,Tablesorter不工作_Python_Html_Html Table_Html Email_Tablesorter - Fatal编程技术网

Python 以HTML电子邮件发送时,Tablesorter不工作

Python 以HTML电子邮件发送时,Tablesorter不工作,python,html,html-table,html-email,tablesorter,Python,Html,Html Table,Html Email,Tablesorter,我试图通过电子邮件发送一个表,当单击该列时,该表将根据该列进行排序 我发现了,这看起来很直截了当 我正在使用python编写html。 所讨论的功能是 def getOpportunitiesTable(opps): #formats html table for email 它接收dict的列表,并应返回html html = "" html += "<head>" html += '<script type="text/javascript" src="http://co

我试图通过电子邮件发送一个表,当单击该列时,该表将根据该列进行排序

我发现了,这看起来很直截了当

我正在使用python编写html。 所讨论的功能是

def getOpportunitiesTable(opps): #formats html table for email
它接收dict的列表,并应返回html

html = ""
html += "<head>"
html += '<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>'
html += '<script type="text/javascript" src="http://mottie.github.com/tablesorter/js/jquery.tablesorter.js"></script>'
html += "</head>"
html += '<table id="opportunities" class="tablesorter">'
html += '<thead><tr><th>Opportunity Name</th><th>Forcasted Close Date</th><th>Pipeline Category</th><th>Stage</th><th>Priority</th></tr></thead>'

html += '<tbody>'
for o in iter(opps):
    html += "<tr>"
    #opportunity name linked to insightly's page

    html += "<td>" + '<a href="https://googleapps.insight.ly/Opportunities/Details/' + str(o['OPPORTUNITY_ID']) + '">'
    try:
        html += o['OPPORTUNITY_NAME'].encode('utf-8')
    except:
        html += '************************'
        logging.info(str(o))
    html += "</a>" + "</td>"
    html += "<td>"
    if 'FORECAST_CLOSE_DATE' in o and o["FORECAST_CLOSE_DATE"] != None: #if fclose date provided format it
        html += datetime.strptime(o["FORECAST_CLOSE_DATE"], '%Y-%m-%d %H:%M:%S').strftime('%Y-%m-%d')
    else: 
        html += ' - '
    html += "</td>"

    html += "<td>" + pipelineCategory[o['PIPELINE_ID']] if o['PIPELINE_ID'] in pipelineCategory else ' - ' + "</td>"
    html += "<td>" + stageName[o['STAGE_ID']] if o['STAGE_ID'] in stageName else ' - ' + "</td>"
    html += "<td>" + str(o["OPPORTUNITY_FIELD_5"]) + "</td>"
    html += "</tr>"

html += '</tbody>'   
html += "</table><br/>"

return html  
html=“”
html+=“”
html+=''
html+=''
html+=“”
html+=''
html+='Casted Close DatePipeline CategoryStagePriority的商机名称'
html+=''
对于iter中的o(opps):
html+=“”
#链接到insightly页面的opportunity名称
html++=“”++’“”
html+=“”
如果o和o中的'FORECAST_CLOSE_DATE'[“FORECAST_CLOSE_DATE”]!=None:#如果提供了fclose DATE,请格式化它
html+=datetime.strtime(o[“预测关闭日期”],“%Y-%m-%d%H:%m:%S”)。strftime(“%Y-%m-%d”)
其他:
html+='-'
html+=“”
html+=“”+pipelineCategory[o['PIPELINE\u ID']]如果pipelineCategory中的o['PIPELINE\u ID']在其他'-'+'
html+=“”+stageName[o['STAGE\u ID']]如果stageName中的o['STAGE\u ID']在其他'-'+'
html+=“”+str(o[“机会”字段(5)])+“”
html+=“”
html+=''
html+=“
” 返回html
我的困惑来自这两行

html += '<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>'
html += '<script type="text/javascript" src="http://mottie.github.com/tablesorter/js/jquery.tablesorter.js"></script>'
html+=''
html+=''
还有一个固有的问题,我是否应该被允许发送一封html电子邮件来处理发送的表


非常感谢您的帮助!

在HTML电子邮件中不可能使用Javascript,因为这会带来很大的安全风险。大多数邮件客户端会删除或忽略HTML消息中的任何脚本

此外,加载远程脚本可能会被许多客户端作为远程内容阻止,并要求用户手动加载远程内容。但即使他们允许这样做,也不允许用户在电子邮件中运行脚本


您最好将该HTML作为附件包含,然后他们可以打开(风险自负),或者将HTML保存在服务器上的某个位置并链接到该附件。

您是否尝试发送包含javascript元素的HTML电子邮件?因为这样做行不通。