This topic is locked

send email if meets two condition

12/1/2006 4:26:18 AM
ASPRunnerPro General questions
S
SteveL author

hey im still learning to program in asp. anyways.. here is what i want to do. i have a table i want to send a auto email to if two conditions are met.
I have a field called Received, and emailsent.

I want to send a email if received is checked to yes and emailsent is set as "no".

here is what i have so far but it doesnt seem to be picking up the 2nd condition

--------------------------------

Function BeforeAdd(dict)
' Parameters:

' dict - Scripting.Dictionary object.

' Each field on the Add form represented as 'Field name'-'Field value' pair
if dict("Received")="Yes" & dict("emailsent") = "no" then

message =""
keys = dict.keys

For n = 0 To dict.Count-1

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

Next
email="steve@networkcar.com"

subject="New data record TEST TEST"
sendmail email, subject, message
end if
BeforeAdd = True
End Function
---------------

also emailsent field is defualt to "no"

how do i set it to "yes" once the email is sent?
thanks again

!!

J
Jane 12/1/2006

Steve,
please see my changes in Bold:

Function BeforeAdd(dict)

' Parameters:

' dict - Scripting.Dictionary object.

' Each field on the Add form represented as 'Field name'-'Field value' pair
if dict("Received")="Yes" and dict("emailsent") = "no" then

message =""
keys = dict.keys

For n = 0 To dict.Count-1

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

Next
email="steve@networkcar.com"

subject="New data record TEST TEST"
sendmail email, subject, message

dict("emailsent")="Yes"
end if
BeforeAdd = True
End Function