需要使用ASP Vbscript代码发送电子邮件附件

时间:2012-08-27 17:30:23

标签: asp-classic vbscript

我正在尝试使用以下代码在传统的ASP应用程序中发送attachemnet。此应用程序从DB获取邮件,来自地址等的邮件。现在,当用户浏览文档然后没有将documnet存储在任何地方(即在数据库或服务器中)时,捕获来自前端,我需要将文档附加为带有下面邮件代码的附件...请建议.. < / p>

sql = "insert INTO RSP_SSR_ENTRY(SR_ID_NBR, SA_ID_NBR, IMO_NBR ,INSPECTION_SEQ_NBR, INSPECTION_DTM, PO_ID_NBR, OPERATIONAL_STATUS_TXT, REPORT_Q2_IND, REPORT_Q3_IND, REPORT_Q4_IND, REPORT_Q5_IND, REPORT_Q6_IND,   REPORT_Q7_IND, REPORT_Q8_IND, REPORT_Q9_IND, REPORT_Q10_IND, REPORT_Q11_IND, REPORT_Q12_IND, REPORT_Q13_IND, REPORT_QA_IND, REPORT_QB_IND, SUBMITTED_DTM) VALUES(0, " & said & ", " & ssr_imo & ", " & ssr_ins_nr & ", " & ssr_ins_date & ", " & ssr_port_id & ", '" & opStat & "', '" & ssr_q2 & "', '" & ssr_q3 & "', '" & ssr_q4 & "', '" & ssr_q5 & "', '" & ssr_q6 & "', '" & ssr_q7 & "', '" & ssr_q8 & "', '" & ssr_q9 & "', '" & ssr_q10 & "', '" & ssr_q11 & "', '" & ssr_q12 & "', '" & ssr_q13 & "','" & ssr_qa & "', '" & ssr_qb & "', "&right_now&")"

        debugNote sql
        session("sqlInsertText") = sql
        Set db1 = Server.CreateObject("ADODB.Connection")
        db1.Open GV_VIEW_DB_String 

        Set rsInsert = db1.Execute(sql)

            session("duplicateInsert_ssr") = false
            set rsInsert = nothing
            Set dbl = nothing 

        'lookup the name of the Ship
        shipName = ssr_ship_name & " ("&ssr_imo&")"

        'send an email for SSR
        mailbody = GV_EMAIL_TOP 
        'mailbody = mailbody & "For processing on " & FormatDateTime(dateadd("d", 1, now()), 1) & "<br />"
        mailbody = mailbody & "Date time of SSR Upload : " & Day(date()) & " " & MonthName(Month(date()), true) & " " & Year(date()) & " " & Hour(time()) & ":" & Minute(time()) &  "<br />"
        mailbody = mailbody & "Name and IMO number of Ship : " & shipName & "<br />"
        mailbody = mailbody & "Inspection number : " & ssr_ins_nr & "<br />"
        mailbody = mailbody & "Submitted by : " & subName  & " (" & subEmail & ")<br />"

        'mailsubject = "S.H.I.P - SSR report has been submitted "
        mailsubject = "SSR report for " & shipName &  "has been submitted "

        ShipEmail mailbody, "SHIP Admin user", GV_SSR_MAIL_TO, "", "", mailsubject

1 个答案:

答案 0 :(得分:1)

要发送文件,必须始终将其(临时)存储在发送邮件的服务器上!

不知道你的ShipEmail函数是什么样的,假设你正在使用CDO.Message,它将是这样的:

Set cdoMessage = CreateObject("CDO.Message") 
cdoMessage.Subject = "Some Message" 
cdoMessage.From = "testfrom@test.com" 
cdoMessage.To = "testto@test.com" 
'cdoMessage.TextBody = "This is some sample message text." 
cdoMessage.HTMLBody = "This is some sample html message text." 
'File on Server!
cdoMessage.AddAttachment "c:\emailpickup\test.txt"
cdoMessage.Send

如果您想要嵌入图片,请查看AddRelatedBodyPart