webForumDet fria alternativet

Lite hjälp ang cdonts mailing

ASP

12 svar · 1 483 visningar · startad av Biasse

Medlem sedan aug. 2003480 inlägg
Frågan#1

Jag fick detta av en snubbe och jag fattar ingenting. Det ska enligt honom lösa problemet att sända mail från ett forum fast telia stoppat det. Jag testade men det händer inte mycket. Helt klart är nått galet :q

index.asp

<form action="send_mail.asp" method="post"> 
Namn : <input type="text" name="namn" size=20> 
E-post : <input type="text" name="email" size=20> 
Meddelande : <textarea name="mess" cols=25 rows=4></textarea> 
<input type="submit" value="Skicka"> 
</form>

send_mail.asp

<%
Dim namn,email,mess 
namn = Request.Form("namn") 
email = Request.Form("email") 
mess = Request.Form("mess") 

Const cdoSendUsingMethod        = "http://schemas.microsoft.com/cdo/configuration/sendusing"
			Const cdoSendUsingPort          = 2
			Const cdoSMTPServer             = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
			Const cdoSMTPServerPort         = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
			Const cdoSMTPConnectionTimeout  = "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
			Const cdoSMTPAuthenticate       = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
			Const cdoBasic                  = 1
			Const cdoSendUserName           = "http://schemas.microsoft.com/cdo/configuration/sendusername"
			Const cdoSendPassword           = "http://schemas.microsoft.com/cdo/configuration/sendpassword"
			
			Dim objConfig  ' As CDO.Configuration
			Dim objMessage ' As CDO.Message
			Dim Fields     ' As ADODB.Fields
			
			' Get a handle on the config object and it's fields
			Set objConfig = Server.CreateObject("CDO.Configuration")
			Set Fields = objConfig.Fields
			
			' Set config fields we care about
			With Fields
				.Item(cdoSendUsingMethod)       = cdoSendUsingPort
				.Item(cdoSMTPServer)            = "smtprelay1.telia.com"
				.Item(cdoSMTPServerPort)        = 25
				.Item(cdoSMTPConnectionTimeout) = 10
				.Item(cdoSMTPAuthenticate)      = cdoBasic
				.Item(cdoSendUserName)          = "name"
				.Item(cdoSendPassword)          = "password"
			
											End With
			
			Set Fields = Nothing
			Set objMessage = Nothing
			Set objConfig = Nothing
%>
Medlem sedan juli 20003 825 inlägg
#2
set CDOMail = Server.CreateObject("CDONTS.NewMail")
	CDOMail.From = "tomten@sverige.se"
	CDOMail.To = "tomten@internet.com"
	CDOMail.Subject = "årets heta lista"
	CDOMail.Body = "Alla Barnen får julklappar utan Sven, för han kan inte hitta hem... :-) "
	CDOMail.Send
Set CDOMail = Nothing

Det är väl inte CDONTS du har ...?? All den koden för det!?

Byt ut tometen -adressen till din egen. Det som i vissa fall kan vara av vikt är att ha samma avsändare dom själva domänen heter.

Som exempel: Din domän är webforum.nu

Vissa webbhotell konfigurerar att din avsändare måste heta i stil med "noreply@webforum.nu"

Are you with!?

Medlem sedan maj 20031 682 inlägg
#3

Vad händer när du använder dig utav den koden?

Får du något felmeddelande?
Har du installerat CDONTS på din webserver?

/red kollade inte på koden så noga. :r

Medlem sedan juli 20003 825 inlägg
#4

Testa att byt från --- till:

.Item(cdoSMTPServer) = "smtprelay1.telia.com"

.Item(cdoSMTPServer) = "mail1.telia.com"

Alltså, server för utgående post. Du ska inte behöva lösenord för den servern... (???)

			' Set config fields we care about
			With Fields
				.Item(cdoSendUsingMethod)       = cdoSendUsingPort
				.Item(cdoSMTPServer)            = "mail1.telia.com"
			'	.Item(cdoSMTPServerPort)        = 25
			'	.Item(cdoSMTPConnectionTimeout) = 10
			'	.Item(cdoSMTPAuthenticate)      = cdoBasic
			'	.Item(cdoSendUserName)          = "name"
			'	.Item(cdoSendPassword)          = "password"
			
			End With

Testa att avmarkera de fem sista raderna. Default port borde vara 25. Bara om du vill ha annan portnummer kan man skriva det...

Medlem sedan aug. 2003480 inlägg
#5

Sitter på jobbet nu men ska testa imorgon. Vad jag förstod ska man skriva in sitt namn/pass i telia mailen så skulle den gå över den. Han menar på att han använde all den koden .. skriptet gick igenom men inget mail kom.

Medlem sedan aug. 2003480 inlägg
#6

En bit till på väg..

Har ju fattat att detta inte är cdonts och fått det att sända mail. Nästa steg är att koppla detta till min mdb.

Tabellen heter "members" & kollumen "mail". Funktionen jag söker är att skicka massmail till alla adresser i "mail". Har provat lite men klarar inte att loopa ur dom samt att tala om för scriptet att hitta dom. Bara själva kopplingen ligger med nu.

<form method="POST">
<p>Skriv ditt meddelande:<br>
<textarea rows="2" name="TextField" cols="20"></textarea></p>
<p>Skriv din e-post adress<br>
<input type="text" name="TextEmail" size="20"></p>
<p><input type="submit" value="Skicka" name="ButtonSend"><input type="reset" value="Töm fält" name="ButtonReset"></p>
</form>

<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\test\mail.mdb" 
Set RecSet = Server.CreateObject("ADODB.Recordset")

SQL = "Select mail from members"

If Request.Form("ButtonSend")<>"" Then SendMail

Sub SendMail

EmailServer="smtprelay1.telia.com"

EmailSubject="Info"
EmailSender="info@info.com"
EmailAddress=Request.Form("TextEmail")
EmailText=Request.Form("TextField")

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = EmailSubject
objMessage.Sender = EmailSender
objMessage.To = EmailAddress
objMessage.TextBody = EmailText

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = EmailServer

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

'smtpconnectiontimeout (typically 10)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10

'cdoSMTPAuthenticate
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

'cdoSendUserName
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxxxxxxx"

'cdoSendPassword
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxxxxxxx"

objMessage.Configuration.Fields.Update
objMessage.Send

Response.Redirect "mail.asp"
End Sub
%>
Medlem sedan juni 20019 519 inlägg
#7

Koppla ditt Recordset med din SQL och loopar ut ditt Recordset.

Recset = conn.Execute(sql)

Do Until Recset.Eof 
' Mail kod här
Recset.Movenext
Loop
Medlem sedan aug. 2003480 inlägg
#8

Hur lägger du in det? Jag får :

Feltyp:
Körningsfel i Microsoft VBScript (0x800A01B6)
Objektet stöder inte egenskapen eller metoden.: 'Eof'
/mail.asp, line 16

Sen måste man koppla kollumen mail till scriptet i detta och hur skriver man in det?

EmailAddress=Request.Form("TextEmail")

Medlem sedan juni 20019 519 inlägg
#9
Set Recset = conn.Execute(sql)

Do Until Recset.Eof 
' Mail kod här
Recset.Movenext
Loop
EmailAddress=Recset("mail")

istället

Medlem sedan aug. 2003480 inlägg
#10

Feltyp:
Kompileringsfel i Microsoft VBScript (0x800A03EA)
Syntaxfel
/mail.asp, line 19
Sub SendMail

<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\diggers\lagret\digelo.mdb" 
Set RecSet = Server.CreateObject("ADODB.Recordset")

SQL = "Select mail from members"
Set Recset = conn.Execute(sql)

Do Until Recset.Eof 

If Request.Form("ButtonSend")<>"" Then SendMail

Sub SendMail

EmailServer="smtprelay1.telia.com" ' Vilken mailserver ska webbsidan använda för att skicka mail

EmailSubject="Info" ' Vad ska stå i subject på mailet
EmailSender="info@info.com" ' Vilken adress ska stå om avsändare
EmailAddress=Recset("mail") ' Vilken e-post adress ska mailet skicka till
EmailText=Request.Form("TextField") ' Vilken text ska stå i mailet

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = EmailSubject
objMessage.Sender = EmailSender
objMessage.To = EmailAddress
objMessage.TextBody = EmailText

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = EmailServer

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

'smtpconnectiontimeout (typically 10)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10

'cdoSMTPAuthenticate
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

'cdoSendUserName
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxxxxxxx"

'cdoSendPassword
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxxxxxxx"

objMessage.Configuration.Fields.Update
objMessage.Send

Response.Redirect "mail.asp"
End Sub

Recset.Movenext
Loop
%>
Medlem sedan juni 20019 519 inlägg
#11

Du kan inte ha en Sub (definitionen) i en loop. Jag tar en titt på detta när jag kommer hem.

Medlem sedan juni 20019 519 inlägg
#12
<%
If Request.Form("ButtonSend")<>"" Then
	Set Conn = Server.CreateObject("ADODB.Connection")
	Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\diggers\lagret\digelo.mdb" 
	Set RecSet = Server.CreateObject("ADODB.Recordset")

	SQL = "Select mail from members"
	Set Recset = conn.Execute(sql)
	Do Until Recset.Eof
		SendMail RecSet("mail") , Request.Form("TextField")
		RecSet.MoveNext
	Loop
	Set RecSet = Nothing
	Conn.Close
	Set Conn = Nothing

	Response.Redirect "mail.asp"
End If

Sub SendMail(mail, message)

	Dim EmailServer, EmailSubject, EmailSender, EmailAddress, EmailText
	EmailServer="smtprelay1.telia.com" ' Vilken mailserver ska webbsidan använda för att skicka mail
	EmailSubject = "Info" ' Vad ska stå i subject på mailet
	EmailSender = "info@info.com" ' Vilken adress ska stå om avsändare
	EmailAddress = mail ' Vilken e-post adress ska mailet skicka till
	EmailText = message ' Vilken text ska stå i mailet

	Set objMessage = CreateObject("CDO.Message")
	objMessage.Subject = EmailSubject
	objMessage.Sender = EmailSender
	objMessage.To = EmailAddress
	objMessage.TextBody = EmailText

	objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

	'Name or IP of Remote SMTP Server
	objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = EmailServer

	'Server port (typically 25)
	objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
	
	'smtpconnectiontimeout (typically 10)
	objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10

	'cdoSMTPAuthenticate
	objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

	'cdoSendUserName
	objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxxxxxxx"

	'cdoSendPassword
	objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxxxxxxx"

	objMessage.Configuration.Fields.Update
	objMessage.Send
	Set objMessage = Nothing
End Sub
%>
Medlem sedan aug. 2003480 inlägg
#13

Gött.. Nu funkar det perfekt.. Trodde "sub" skulle vara med. Tackar

271 ms totalt · 4 externa anrop · v20260731065814-full.6fe65c25
122 ms — deklarationer (db)
0 ms — hämta statistik (cache)
143 ms — hämta tråd, inlägg och bilagor (db)
123 ms — ändringar (db)