我正在使用经典ASP并通过CDO发送电子邮件,我需要将以下内容作为电子邮件正文中的链接发送。
http://example.co.uk/Uploaded_Files/<%= RealFileName%GT;
> ' we are sending a text email.. simply switch the comments around to
> send an html email instead ObjSendMail.HTMLBody = "<h2 align=center>"
> & "<a href="http://example.co.uk/Uploaded_Files/" " &
> Request.Form("filenamex") & "">View File</a>"
上面的代码返回时出现此错误,
Microsoft VBScript编译错误'800a0401'
预期声明结束
答案 0 :(得分:1)
执行以下操作
<%
html = "<a href=""http://example.co.uk/Uploaded_Files/" & RealFileName & """></a>"
Set cdoMessage = Server.CreateObject("CDO.Message")
cdoMessage.From = "email_from@domain.com"
cdoMessage.To = "email_to@domain.com"
cdoMessage.Bcc = "email_bcc@domain.com"
cdoMessage.Subject = "subject"
cdoMessage.ReplyTo = "email_replyto@domain.com"
cdoMessage.HTMLBody = html
sch = "http://schemas.microsoft.com/cdo/configuration/"
cdoMessage.Configuration.Fields.Item(sch & "smtpserver") = smtp.domain.com
cdoMessage.Configuration.Fields.Item(sch & "sendusername") = user
cdoMessage.Configuration.Fields.Item(sch & "sendpassword") = pass
cdoMessage.Configuration.Fields.Item(sch & "smtpserverport") = 587
cdoMessage.Configuration.Fields.Item(sch & "smtpusessl") = False
cdoMessage.Configuration.Fields.Item(sch & "smtpconnectiontimeout") = 60
cdoMessage.Configuration.Fields.Item(sch & "smtpauthenticate") = 1
cdoMessage.Configuration.Fields.Item(sch & "sendusing") = 2
cdoMessage.Configuration.Fields.update
cdoMessage.Send
Set cdoMessage = Nothing
%>
答案 1 :(得分:0)
问题是额外的引号,试试这个:
ObjSendMail.HTMLBody = "<h2 align=center><a href='example.co.uk/Uploaded_Files/" & Request.Form("filenamex") & "'>View File</a>"