CDO mail og asp.
Hej E.Jeg prøver at oprette en mail via CDO mail. Dette virker fint indtil jeg vil hendte indholdet fra en database.
Her er min kode:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test Mail</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
Dim myMail
Set myMail = CreateObject("CDONTS.NewMail")
HTML = "<!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">" & NL
HTML = HTML & "<html>"
HTML = HTML & "<head>"
HTML = HTML & "<meta http-equiv=""Content-Type"""
HTML = HTML & "HTML = HTML & ""content=""text/html; charset=iso-8859-1"">"""
HTML = HTML & "<title>Sample NewMail</title>"
HTML = HTML & "<body>"
HTML = HTML & "<p>"
HTML = HTML & "<%"
HTML = HTML & "SET DbObj=Server.CreateObject ("ADODB.Connection")"
HTML = HTML & "DbObj.Open "hcb_itcnewsletter""
HTML = HTML & "SET tabel=DbObj.Execute("SELECT ID, Overskrift, Tekst from Indlaeg where EmneID = 1") "
HTML = HTML & " If Not (tabel.BOF Or tabel.EOF) Then"
HTML = HTML & " Do While Not tabel.EOF"
HTML = HTML & "%>"
HTML = HTML & "</p>"
HTML = HTML & "<table width="100%" border="0">"
HTML = HTML & " <tr> "
HTML = HTML & " <td width="175" valign="top"><strong><%=tabel("Overskrift")%></strong></td>"
HTML = HTML & " <td><%=tabel("Tekst")%> </td>"
HTML = HTML & " </tr>"
HTML = HTML & "</table>"
HTML = HTML & "<hr>"
HTML = HTML & "<% tabel.movenext"
HTML = HTML & "loop"
HTML = HTML & "else%>"
HTML = HTML & "<br>"
HTML = HTML & "<% end if"
HTML = HTML & "tabel.close"
HTML = HTML & "DbObj.close%>"
HTML = HTML & "</body>"
HTML = HTML & "</html>"
myMail.From = "e-mail"
myMail.To = "e-mail"
myMail.Subject = "Sample Message"
myMail.BodyFormat = 0 ' CdoBodyFormatHTML
myMail.MailFormat = 0 ' CdoMailFormatMime
myMail.Importance = 1
myMail.Body = HTML
myMail.Send
Set myMail = Nothing
%>
Mail sendt
</body>
</html>
ASP koden virker fint i min "normal" fil.
