2013-04-25 6 views
0

해당 열을 클릭하면 열을 기준으로 정렬 할 테이블을 전자 메일로 보내려고합니다.HTML로 보낸 경우 Tablesorter가 작동하지 않음 이메일

나는 http://tablesorter.com/docs/을 발견했으며 매우 직설적이었습니다.

저는 HTML을 작성하기 위해 파이썬을 사용하고 있습니다. 문제의 함수는 딕셔너리의의 목록에 취해 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 += '<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>' 

또한 고유의 질문을 반환해야

def getOpportunitiesTable(opps): #formats html table for email 

입니다 내가 보낸 테이블을 조작하는 html 이메일을 보내도록 허용해야합니까?

도움을 주시면 감사하겠습니다.

+0

자바 스크립트 요소가 포함 된 HTML 이메일을 보내시겠습니까? 왜냐하면 그건 효과가 없기 때문이죠. – samanthasquared

답변

1

HTML 이메일에서 Javascript를 사용할 수 없으므로 보안 상 큰 위험이 따릅니다. 대부분의 메일 클라이언트는 HTML 메시지의 모든 스크립트를 제거하거나 무시합니다.

또한 원격 스크립트로드는 많은 클라이언트에서 원격 콘텐츠로 차단되어 사용자가 수동으로 원격 콘텐츠를로드해야 할 수 있습니다. 그러나 그들이 그것을 허용하더라도, 여전히 전자 메일에서 스크립트를 실행할 수는 없습니다.

가장 좋은 방법은 해당 HTML을 첨부하여 자신의 위험 부담으로 열어 보거나 서버의 HTML을 어딘가에 저장하고 링크 할 수 있습니다.

관련 문제