jeg har en lille newsliste / mail-liste, som jeg gerne vil have
til at sende html mails ud.
jeg kan kaste koden direkte ind i form-feltet, og så køre den,
men jeg kan ikke få den til at smide variabler ind i
html-mailen..
findes der et projekt der kan sådan noget, eller en der kan
hjælpe mig lidt på vej...?
Scriptet ser sådan ud nu...
<%
Dim rsNews, recipients, strCount
Set rsNews = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM newsLetter WHERE confirm = 'yes';"
rsNews.Open strSQL, objConn, adOpenForwardOnly,
adLockOptimistic, adCmdText
strCount = 0
If Not rsNews.EOF Then
Do While Not rsNews.EOF
recipients = recipients & rsNews("email") & ","
strCount = strCount + 1
rsNews.MoveNext
Loop
recipients = Left(recipients,Len(recipients)-1)
End If
rsNews.Close
Set rsNews = Nothing
If Request.Form("sent") = "" Then
%>
<div align="center">
<br /><br />
<span
style="font-family:arial;font-size:12px;color:#000080;font-weight
:bold">
Der er tilmeldte i systemet...
</span>
<p>
<span
style="font-family:arial;font-size:12px;color:#000080;font-weight
:bold">
send til alle med:
</span>
<span style="font-size: 12px; color: #000080">
<span style="font-family: arial; font-weight: 700"><%=
recipients %></span></span><br /><br />
</p>
<form action="mail.asp" method="post">
<input type="hidden" name="sent" value="yes" />
<table width="50%">
<tr>
<td>til : <input type="text" name="recipients"
value="<%= recipients %>" size="20" /></td>
</tr>
<tr>
<td>
<textarea name="msg" cols="50" rows="10">
</textarea>
</td>
</tr>
<tr>
<td align="center"><input type="radio" name="version"
value="html" checked /> <span
style="font-family:arial;font-size:12px;color:#000080;font-weight
:bold">HTML <input type="radio" name="version"
value="text" /> TEKST</span></td>
</tr>
<tr>
<td align="center"><input type="submit" value="send" /></td>
</tr>
</table>
</form>
</div>
<%
Else
Dim mailObj, cdoMessage, cdoConfig, addrList, strEmailMsg,
subject
Dim strEmail
strEmail = Request.Form("recipients")
subject = strSiteTitle & " nyhedsbrev"
'send email so subscriber can confirm
strEmailMsg = Replace(Request.Form("msg"),Chr(13) & Chr(10),"<br
/>")
If Request.Form("version") = "html" Then
strEmailMsg = strEmailMsg & strFooter
Else
strEmailMsg = Replace(strEmailMsg & strFooter,"<br />",Chr(13)
& Chr(10))
End If
'Send email based on mail component.
'Send email (CDONTS version). Note: CDONTS doesn't support a
reply-to
'address and has no error checking.
if mailComp = "CDONTS" then
set mailObj = Server.CreateObject("CDONTS.NewMail")
If Request.Form("version") = "html" Then
mailObj.BodyFormat = 0
mailObj.MailFormat = 0
Else
mailObj.BodyFormat = 1
End If
mailObj.From = fromAddr
mailObj.To = strEmail
mailObj.Subject = subject
mailObj.Body = strEmailMsg
mailObj.Send
set mailObj = Nothing
end if
'Send email (CDOSYS version).
if mailComp = "CDOSYS" then
set cdoMessage = Server.CreateObject("CDO.Message")
set cdoConfig = Server.CreateObject("CDO.Configuration")
cdoConfig.Fields("
http://schemas.microsoft.com/cdo/configuration/
sendusing") = 2
cdoConfig.Fields("
http://schemas.microsoft.com/cdo/configuration/
smtpserver") = smtpServer
cdoConfig.Fields.Update
set cdoMessage.Configuration = cdoConfig
cdoMessage.From = fromAddr
cdoMessage.To = strEmail
cdoMessage.Subject = subject
If Request.Form("version") = "html" Then
cdoMessage.HtmlBody = strEmailMsg
Else
cdoMessage.TextBody = strEmailMsg
End If
on error resume next
cdoMessage.Send
if Err.Number <> 0 then
SendMail = "Email send failed: " & Err.Description & "."
end if
set cdoMessage = Nothing
set cdoConfig = Nothing
end if
'Send email (JMail version).
if mailComp = "JMail" then
set mailObj = Server.CreateObject("JMail.SMTPMail")
mailObj.Silent = true
mailObj.ServerAddress = smtpServer
mailObj.Sender = fromAddr
mailObj.ReplyTo = fromAddr
mailObj.Subject = subject
addrList = Split(strEmail, ",")
for each addr in addrList
mailObj.AddRecipient Trim(addr)
next
If Request.Form("version") = "html" Then mailObj.ContentType =
"text/html"
mailObj.Body = strEmailMsg
if not mailObj.Execute then
SendMail = "Fejl under udsendelse af mail: " &
mailObj.ErrorMessage & "."
end if
end if
'Send email (ASPMail version).
if mailComp = "ASPMail" then
set mailObj = Server.CreateObject("SMTPsvg.Mailer")
mailObj.FromAddress = fromAddr
mailObj.RemoteHost = smtpServer
mailObj.ReplyTo = fromAddr
for each addr in Split(strEmail, ",")
mailObj.AddRecipient "", Trim(addr)
next
mailObj.Subject = subject
If Request.Form("version") = "html" Then mailObj.ContentType =
"text/html"
mailObj.BodyText = strEmailMsg
if not mailObj.SendMail then
SendMail = "Email send failed: " & mailObj.Response & "."
end if
end if
If Err.Number <> 0 then
Response.Write SendMail
Else
Response.Write "<div align=""center""><br /><br />" & _
"<span
style=""font-family:arial;font-size:12px;color:#000080;font-weigh
t:bold;text-align:left"">" & _
"Success! nyhedsbrevet er
udsendt!</span></div>"
End If
End If
objConn.Close
Set objConn = Nothing
--
Vil du lære at kode HTML, XHTML, CSS, SSI eller ASP?
- Pædagogiske tutorials på dansk
- Kom godt i gang med koderne
KLIK HER! =>
http://www.html.dk/tutorials