This topic is locked

Email sends mutiple lines of same record

7/1/2008 6:00:39 AM
ASPRunnerPro General questions
jfr author

Hello,
The following code

if dict("iAlert_klant")="Ja" then

Dim dkeys

message =""
dkeys = dict.keys

For n = 0 To dict.Count-1

message = message & vbcrlf & "Klantnaam" & " : " & dict("Naam") & vbrclf

message = message & vbcrlf & "Straat" & " : " & dict("Faktuur_straat") & vbrclf

message = message & vbcrlf & "Huisnummer" & " : " & dict("Faktuur_huisnummer") & vbrclf

message = message & vbcrlf & "Postcode" & " : " & dict("Faktuur_postcode") & vbrclf

message = message & vbcrlf & "Woonplaats" & " : " & dict("Faktuur_woonplaats") & vbrclf

message = message & vbcrlf & "Land" & " : " & dict("Faktuur_land") & vbrclf

Next


email="Offerte@xxx.nl"

subject="Nieuwe iAlert Personal relatie"



sendmail email, subject, message

end if


Gives the following output;

Klantnaam : John Franken

Straat : Beechavenue

Huisnummer : 129

Postcode : 1119 RB

Woonplaats : Schiphol-Rijk

Land : Nederland

Klantnaam : John Franken

Straat : Beechavenue

Huisnummer : 129

Postcode : 1119 RB

Woonplaats : Schiphol-Rijk

Land : Nederland

Klantnaam : John Franken

Straat : Beechavenue

Huisnummer : 129

Postcode : 1119 RB

Woonplaats : Schiphol-Rijk

Land : Nederland

Klantnaam : John Franken

Straat : Beechavenue

Huisnummer : 129

Postcode : 1119 RB

Woonplaats : Schiphol-Rijk

Land : Nederland

Klantnaam : John Franken

Straat : Beechavenue

Huisnummer : 129

Postcode : 1119 RB

Woonplaats : Schiphol-Rijk

Land : Nederland

Klantnaam : John Franken

Straat : Beechavenue

Huisnummer : 129

Postcode : 1119 RB

Woonplaats : Schiphol-Rijk

Land : Nederland

Klantnaam : John Franken

Straat : Beechavenue

Huisnummer : 129
In other words, I am forgetting something.

The output should be;
Klantnaam : John Franken

Straat : Beechavenue

Huisnummer : 129

Postcode : 1119 RB

Woonplaats : Schiphol-Rijk

Land : Nederland
I know the reason, but don't know how to solve it.
Thanks a lot,

John

P
Philip 7/1/2008

Hi,

as far as I can see the point is here:

eliminate in your code this part: For n = 0 To dict.Count-1

Regards,

Philip

Hello,

The following code

if dict("iAlert_klant")="Ja" then

Dim dkeys

message =""
dkeys = dict.keys

For n = 0 To dict.Count-1

message = message & vbcrlf & "Klantnaam" & " : " & dict("Naam") & vbrclf

message = message & vbcrlf & "Straat" & " : " & dict("Faktuur_straat") & vbrclf

message = message & vbcrlf & "Huisnummer" & " : " & dict("Faktuur_huisnummer") & vbrclf

message = message & vbcrlf & "Postcode" & " : " & dict("Faktuur_postcode") & vbrclf

message = message & vbcrlf & "Woonplaats" & " : " & dict("Faktuur_woonplaats") & vbrclf

message = message & vbcrlf & "Land" & " : " & dict("Faktuur_land") & vbrclf

Next
email="Offerte@xxx.nl"

subject="Nieuwe iAlert Personal relatie"
sendmail email, subject, message

end if


Gives the following output;

Klantnaam : John Franken

Straat : Beechavenue

Huisnummer : 129

Postcode : 1119 RB

Woonplaats : Schiphol-Rijk

Land : Nederland

Klantnaam : John Franken

Straat : Beechavenue

Huisnummer : 129

Postcode : 1119 RB

Woonplaats : Schiphol-Rijk

Land : Nederland

Klantnaam : John Franken

Straat : Beechavenue

Huisnummer : 129

Postcode : 1119 RB

Woonplaats : Schiphol-Rijk

Land : Nederland

Klantnaam : John Franken

Straat : Beechavenue

Huisnummer : 129

Postcode : 1119 RB

Woonplaats : Schiphol-Rijk

Land : Nederland

Klantnaam : John Franken

Straat : Beechavenue

Huisnummer : 129

Postcode : 1119 RB

Woonplaats : Schiphol-Rijk

Land : Nederland

Klantnaam : John Franken

Straat : Beechavenue

Huisnummer : 129

Postcode : 1119 RB

Woonplaats : Schiphol-Rijk

Land : Nederland

Klantnaam : John Franken

Straat : Beechavenue

Huisnummer : 129
In other words, I am forgetting something.

The output should be;
Klantnaam : John Franken

Straat : Beechavenue

Huisnummer : 129

Postcode : 1119 RB

Woonplaats : Schiphol-Rijk

Land : Nederland
I know the reason, but don't know how to solve it.
Thanks a lot,

John

jfr author 7/1/2008

Hi Philip,
Unfortunately that didn't solve it.

That caused the following error

Error Type:

Microsoft VBScript compilation (0x800A041F)

Unexpected 'Next'

/DIT-order/include/Verkooprelatie_events.asp, line 34

Next


John

P
Philip 7/1/2008

John
here a sample that is working in a "Before record added" event on my website:
****


strSQLExists = "select
from Anmeldejournal where [T-ID_Liz]='" & Session("A_ID_Turnier") & Session("H_Lizenz_AOA") &"'"

set rsExists = CreateObject("ADODB.Recordset")

rsExists.Open strSQLExists, dbConnection
if rsExists.eof then

' if record NOT exists do something
do something

else

' if record exist do something else
do something
end if

rsExists.Close : set rsExists = Nothing
'****
Send email with new data ****
message ="Hallo " & dict("HF_Vorname_AOA") & " und " & dict("H_Name_AOA") & vbcrlf & vbcrlf

message = message & "Deine Anmeldung für die Lizenz-Nr. " & dict("H_Lizenz_AOA") & " (" & dict("H_Kategorie_AOA") & " " & dict("H_Klasse_AOA") & ") wurde in AOA registriert." & vbcrlf

message = message & "Mutationen kannst Du jederzeit online durchführen. Benutze dafür folgenden Link:" & vbcrlf

message = message & "(einfach beim gewünschten Turnier auf 'mutieren' klicken)" & vbcrlf & " " & vbcrlf
'etc.
email=dict("HF_email_AOA")

subject="Anmeldung bei " & dict("T_Veranstalter_AOA") & " - " & FormatDateTime(dict("T_Datum_AOA"), 2)
sendmail email, subject, message
BeforeAdd = True

jfr author 7/2/2008

Dear Philip,
Thanks so much!!
The following code does it all;

' Parameters:

' dict - Scripting.Dictionary object.

' Each field on the Add form is represented as a 'Field name'-'Field value' pair
'********** Send email with new data ************

' do not forget to setup email parameters like From, SMTP server etc

' on 'Security->User login settings' dialog
'********** Check if specific record exists ************

strSQLExists = "select * from Verkooprelatie where [Naam]='" & session("Naam") & "'"

set rsExists = CreateObject("ADODB.Recordset")

rsExists.Open strSQLExists, dbConnection
if not rsExists.eof then

' if record exists do something
else

' if dont exist do something else

'do something
end if

rsExists.Close : set rsExists = Nothing
if dict("iAlert_klant")="Ja" then

'send email with new data'
message ="Beste Peter, Elco" & vbcrlf & vbcrlf & "Hierbij een nieuw aangemelde iAlert Personal Relatie" & vbcrlf & vbcrlf
message = message & vbcrlf & "Klantnaam" & " : " & dict("Naam") & vbrclf

message = message & vbcrlf & "Straat" & " : " & dict("Faktuur_straat") & vbrclf

message = message & vbcrlf & "Huisnummer" & " : " & dict("Faktuur_huisnummer") & vbrclf

message = message & vbcrlf & "Postcode" & " : " & dict("Faktuur_postcode") & vbrclf

message = message & vbcrlf & "Woonplaats" & " : " & dict("Faktuur_woonplaats") & vbrclf

message = message & vbcrlf & "Land" & " : " & dict("Faktuur_land") & vbrclf & vbrclf & vbrclf


email="Elco@ligen.nl;peter@cults.nl"

subject="Nieuwe iAlert Personal relatie"



sendmail email, subject, message
BeforeAdd = True
end if
'********** Send email with new data ************

' do not forget to setup email parameters like From, SMTP server etc

' on 'Security->User login settings' dialog
message =""
dkeys = dict.keys

For n = 0 To dict.Count-1

message = message & dkeys(n) & " : " & dict(dkeys(n)) & vbcrlf

Next



email="Offerte@gen.nl"

subject="Nieuwe verkooprelatie"



sendmail email, subject, message
'********** Redirect to another page ************

Response.Redirect "Verkooprelatie_list.asp"


Simly love this tool!!
Best regards,

John