Send_Mail Function
寄發mail Function,利用java mail寄信,格式為HTML
可寫至程式中的寄發MAIL
FUNCTION sendmail()
DEFINE l_str STRING
DEFINE l_sql STRING
DEFINE l_pmd07 LIKE pmd_file.pmd07
DEFINE l_pmd02 LIKE pmd_file.pmd02
DEFINE l_cn LIKE type_file.num5
DEFINE ls_temppath STRING
DEFINE ls_filename STRING
WHENEVER ERROR CALL cl_err_msg_log
LET ls_temppath = FGL_GETENV("TEMPDIR")
LET ls_filename = ls_temppath.trim(),"/apmt420_" || FGL_GETPID() || ".htm"
INITIALIZE g_xml.* TO NULL
LET g_xml.subject = "XX股份有限公司-自動發佈通知"
LET l_pmd07 = ''
LET l_str = ''
LET l_cn = 0
# IF NOT cl_null(g_wpc.wpc03) THEN
# LET l_sql = "SELECT pmd07,pmd02 FROM pmd_file WHERE pmd07 IS NOT NULL AND pmd08 = 'Y' AND pmd01 = '",g_wpc.wpc03,"'"
# PREPARE pmd_pr2 FROM l_sql
# DECLARE pmd_curs2 CURSOR FOR pmd_pr2
# FOREACH pmd_curs2 INTO l_pmd07,l_pmd02
# IF l_cn = 0 THEN
# LET l_str = l_pmd07,":",l_pmd02 CLIPPED
# ELSE
# LET l_str = l_str,";",l_pmd07,":",l_pmd02 CLIPPED
# END IF
# LET l_cn = l_cn + 1
# END FOREACH
# END IF
LET g_xml.body = ls_filename.trim()
LET g_xml.sender = "tiptop@dsc.com.tw:top30"
LET g_xml.recipient = "felix.fu@XXXXXXXXX" #l_str.trim()
LET g_channel = base.Channel.create()
CALL g_channel.openFile( ls_filename CLIPPED, "a" )
CALL g_channel.setDelimiter("")
CALL t420_head()
CALL t420_detail()
CALL t420_tail()
CALL g_channel.close()
CALL cl_jmail()
RUN "rm -f " || ls_filename
RUN "rm -f " || FGL_GETPID() || ".xml"
END FUNCTION
FUNCTION t420_head()
DEFINE l_codeset STRING
DEFINE l_lang STRING
CASE g_lang
WHEN '0'
LET l_lang = "zh-tw"
WHEN '2'
LET l_lang = "zh-cn"
OTHERWISE
LET l_lang = "en"
END CASE
LET l_codeset = "UTF-8"
LET g_tmpstr =' ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='<html> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='<head> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='<meta http-equiv="Content-Language" content="',l_lang,'"> ' CALL g_channel.write(g_tmpstr.trimRight()) #No.FUN-740189
LET g_tmpstr ='<meta http-equiv="Content-Type" content="text/html; charset=',l_codeset,'">' CALL g_channel.write(g_tmpstr.trimRight()) #No.FUN-740189
LET g_tmpstr ='<title>',g_xml.subject CLIPPED,'</title> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='<style><!-- ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='div.Section1 ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' {page:Section1;} ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' p.MsoNormal ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' {mso-style-parent:""; ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' margin-bottom:.0001pt; ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' font-size:12.0pt; ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' font-family:新細明體; ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' margin-left:0cm; margin-right:0cm; margin-top:0cm} ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='span.GramE ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' {} --> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='</style> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='</head> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='<body> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='<div class="Section1"> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='<p class="MsoNormal"> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='<span style="COLOR: #000000; FONT-FAMILY: 新細明體; font-weight:700"> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='<font size="4"><i></i> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' ',g_xml.subject CLIPPED,' ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='</font></span></p></div> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='<p class="MsoNormal"></p> ' CALL g_channel.write(g_tmpstr.trimRight())
END FUNCTION
FUNCTION t420_detail()
DEFINE ls_zl15 STRING
LET g_tmpstr ='<table border="1" style="border-collapse: collapse" width="600" id="table2"> ' CALL g_channel.write(g_tmpstr.trimRight())
LET ls_zl15 = g_wpc.wpc01 CLIPPED
LET g_tmpstr ='<tr><td width="100" bgcolor="#00AA00" align="center"> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' <p style="line-height: 150%"><b> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' <font color="#FFFF00" size="3">單據編號</font></b></td> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' <td><p style="line-height: 150%"><font size="3">',ls_zl15.trim(),'</font></td> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='</tr> ' CALL g_channel.write(g_tmpstr.trimRight())
LET ls_zl15 = g_wpc.wpc04 CLIPPED
LET g_tmpstr ='<tr><td width="100" bgcolor="#00AA00" align="center"> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' <p style="line-height: 150%"><b> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' <font color="#FFFF00" size="3">單據項次</font></b></td> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' <td><p style="line-height: 150%"><font size="3">',ls_zl15.trim(),'</font></td> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='</tr> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='<tr><td width="100" bgcolor="#00AA00" align="center"> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' <p style="line-height: 150%"><b> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' <font color="#FFFF00" size="3">說 明</font></b></td> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' <td><p style="line-height: 150%"><font size="3">',g_wpc.wpc05 CLIPPED,'</font></td> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='</tr> ' CALL g_channel.write(g_tmpstr.trimRight())
# LET g_tmpstr ='<tr><td width="100" bgcolor="#00AA00" align="center"> ' CALL g_channel.write(g_tmpstr.trimRight())
# LET g_tmpstr =' <p style="line-height: 150%"><b> ' CALL g_channel.write(g_tmpstr.trimRight())
# LET g_tmpstr =' <font color="#FFFF00" size="3">品名規格</font></b></td> ' CALL g_channel.write(g_tmpstr.trimRight())
# LET g_tmpstr =' <td><p style="line-height: 150%"><font size="3">',g_wpc.wpc06 CLIPPED,'</font></td> ' CALL g_channel.write(g_tmpstr.trimRight())
# LET g_tmpstr ='</tr> ' CALL g_channel.write(g_tmpstr.trimRight())
# LET g_tmpstr ='<tr><td width="100" bgcolor="#00AA00" align="center"> ' CALL g_channel.write(g_tmpstr.trimRight())
# LET g_tmpstr =' <p style="line-height: 150%"><b> ' CALL g_channel.write(g_tmpstr.trimRight())
# LET g_tmpstr =' <font color="#FFFF00" size="3">需求單位</font></b></td> ' CALL g_channel.write(g_tmpstr.trimRight())
# LET g_tmpstr =' <td><p style="line-height: 150%"><font size="3">',g_wpc.wpc07 CLIPPED,'</font></td> ' CALL g_channel.write(g_tmpstr.trimRight())
# LET g_tmpstr ='</tr> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='<tr><td width="100" bgcolor="#00AA00" align="center"> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' <p style="line-height: 150%"><b> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' <font color="#FFFF00" size="3">備 註</font></b></td> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' <td><p style="line-height: 150%"><font size="3">',g_wpc.wpc08 CLIPPED,'</font></td> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='</tr></table><p class="MsoNormal"></p> ' CALL g_channel.write(g_tmpstr.trimRight())
END FUNCTION
FUNCTION t420_tail()
DEFINE l_time DATETIME YEAR TO SECOND
DEFINE lc_zx02 LIKE zx_file.zx02
LET g_tmpstr ='<p class="MsoNormal"> </p> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='<table border="1" style="border-collapse: collapse" width="600" id="table3"> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='<tr><td width="50%" bgcolor="#00AA00" align="center"> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' <p style="line-height: 150%"><font color="#FFFF00" size="3"> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' 寄發人員</font></td> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' <td width="50%" bgcolor="#00AA00" align="center"> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' <p style="line-height: 150%"><font color="#FFFF00" size="3"> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' 寄發時間</font></td> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='</tr> ' CALL g_channel.write(g_tmpstr.trimRight())
LET l_time = CURRENT YEAR TO SECOND
SELECT zx02 INTO lc_zx02 FROM zx_file WHERE zx01=g_user
LET g_tmpstr ='<tr><td width="50%" align="center"> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' <p style="line-height: 150%"><font size="3"> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' ',g_user CLIPPED,' / ',lc_zx02 CLIPPED,'</font></td> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' <td width="50%" align="center"> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr =' <p style="line-height: 150%"><font size="3">',l_time CLIPPED,'</font></td>' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='</tr> ' CALL g_channel.write(g_tmpstr.trimRight())
LET g_tmpstr ='</table></body></html> ' CALL g_channel.write(g_tmpstr.trimRight())
END FUNCTION