<%
Dim mySmartUpload
Dim sendername,subject,body, fil, file
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
mySmartUpload.Upload
MySmartUpload.Save("E:\\bilaga")
sendername=mySmartUpload.Form("sendername")
subject=mySmartUpload.Form("subject")
body=mySmartUpload.Form("body")
skolan=mySmartUpload.Form("skola")
For each file In mySmartUpload.Files
fil=file.FileName
Next
On error resume next
Server.ScriptTimeOut = 180
Dim strSQL
Dim mySmartMail
Set mySmartMail = Server.CreateObject("aspSmartMail.SmartMail")
' Mail Server
' ***********
mySmartMail.Server = "****"
' From
' ****
mySmartMail.SenderName = SenderName
mySmartMail.SenderAddress = "*******"
' Message
' *******
mySmartMail.Subject = Subject
mySmartMail.Body = Body
if not fil="" then
mySmartMail.Attachments.Add Server.MapPath("\bilaga\"&fil&""),, false
end if
'sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\*******"
'Set Conn = Server.CreateObject("ADODB.Connection")
'Conn.Open sConn
if Err.Number <> 0 then
Response.Write "Can't connect to the DataBase, Please check value of Data Source in the HTML form."
end if
' Create the RecordSet
' ********************
strSQL = "SELECT MAIL FROM mail where skola=" & skolan
Set Rs = Server.CreateObject("ADODB.recordset")
Set Rs.ActiveConnection = Conn
Rs.Source = strSQL
Rs.Open
Do while not Rs.EOF
' To
' **
if Rs("NAMN")<>"" Then
mySmartMail.Recipients.Add Rs("MAIL")
else
mySmartMail.Recipients.Add Rs("MAIL")
end if
' Send the message
' ****************
mySmartMail.SendMail
if err.number <> 0 then
response.write("<br>Error n°: " & err.number - vbobjecterror & "=" & err.description & "<br>")
else
Response.Write "<br>aspSmartMail has sent your message to " & mySmartMail.Recipients.Item(1).Address
end if
mySmartMail.Recipients.Clear
Rs.MoveNext
Loop
' Destruction
' ***********
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile "****\bilaga\"&fil&"", False
Set objFSO = Nothing
response.redirect "../default.asp?kat=nyhetsbrev&sida=skriv.asp&status=ok"
Rs.Close
Conn.Close
Set Rs = Nothing
Set Conn = Nothing
set mySmartMail = nothing
%>
När jag kör koden så tuggar den jättelänge och sen så skriver den att det inte finns några mottagare. I databasen ligger adresserna i tabellen mail och fältet mail. finns även ett fält som heter skola som kan vara samma bakom många mailadresser. Vad har jag gjort för fel?
Felmedelandet kommer från. Mailkomponenten och pekar inte på någon rad.
Ser ut så här:
SELECT * FROM mail where skola=Samskolan
Error n°: 80=There is no Recipient. (verify the address list)