This topic is locked

SENDMAIL

11/9/2006 5:31:34 AM
ASPRunnerPro General questions
N
NigelEtienne author

I have just upgraded to the latest version of ASPRunner and converted my project. The sendmail event nolonger works. Here is the code:

include/commonfunctions.asp

Set myMail=CreateObject("CDO.Message")

myMail.Subject = subject

myMail.From=cfrom

myMail.To=email

myMail.HTMLBody= message

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

'Name or IP of remote SMTP server

myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver";)=csmtpserver

'Server port

myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport";)=csmtpport

' SMTP username and passwords

myMail.Configuration.Fields.Item("http://schemas.microsoft.com/c­do/configuration/sendpassword";) = csmtppassword

myMail.Configuration.Fields.Item("http://schemas.microsoft.com/c­do/configuration/sendusername";) = csmtpuser

myMail.Configuration.Fields.Update

myMail.Send

Set myMail = Nothing
Sub AfterAdd()

'** Send simple email ****

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

' on 'Security->User login settings' dialog

'

if getrequestform("LeaveType")= 8 then

'

Response.Redirect "tblLeaveRequests_list.asp?action=backtolist"

'

else

'

email=GetRequestForm("EmailAddress")

'message= "Start Date: " & GetRequestForm("LeaveStart") & "
" & "End Date: " & GetRequestForm("LeaveEnd")& "
" & "Notes: " & GetRequestForm("AdditionalInfo")& "
" & "
" & "Please authorise by logging onto the " & "<A HREF=""http:\\bbcapps1046\GFC_LEAVE"">""Annual Leave Website""</a>"

message ="<table border = 1 cellpadding=3 cellspacing=0 style=border-collapse: collapse bordercolor=#111111 width=235><tr><td width=135 bgcolor=#83C7C6 align=right><b>Start Date :</b></td><td width=97>" & GetRequestForm("LeaveStart") & "</td></tr><tr><td width=135 bgcolor=#83C7C6 align=right><b>End Date :</b></td><td width=97>" & GetRequestForm("LeaveEnd") &"</td></tr><tr><td width=135 bgcolor=#83C7C6 align=right><b>Notes :</b></td><td width=97>" & GetRequestForm("AdditionalInfo")& "</td></tr></table>
Please authorize by clicking " & "<a href=http:\\bbcapps1046\GFC_LEAVE\login.asp>here</a> and logging onto the GFC Leave database.<BR>Select <font color=#800080>Main Menu</font> and you will find this request under <font color=#800080>Direct Reports - Outstanding Leave.</font></p>"

'

If dict("LeaveType") = 1 then

subject="New ANNUAL Leave Request from " & GetRequestForm("MyName")

ElseIf dict("LeaveType") = 2 then

subject="New LONG SERVICE Leave Request from " & GetRequestForm("MyName")

ElseIf dict("LeaveType") = 3 then

subject="New ADDITIONAL Leave Request from " & GetRequestForm("MyName")

ElseIf dict("LeaveType") = 4 then

subject="New COMPASSIONATE Leave Request from " & GetRequestForm("MyName")

ElseIf dict("LeaveType") = 5 then

subject="New MATERNITY Leave Request from " & GetRequestForm("MyName")

ElseIf dict("LeaveType") = 6 then

subject="New TRAINING Leave Request from " & GetRequestForm("MyName")

ElseIf dict("LeaveType") = 7 then

subject="New STUDY Leave Request from " & GetRequestForm("MyName")

ElseIf dict("LeaveType") = 9 then

subject="New BOUGHT/(SOLD) Leave Request from " & GetRequestForm("MyName")

ElseIf dict("LeaveType") = 10 then

subject="New HOME WORKING Request from " & GetRequestForm("MyName")

else

subject="New Leave Request from " & GetRequestForm("MyName")

'

end if

'

sendmail email, subject, message

'

Response.Redirect "tblLeaveRequests_list.asp?action=backtolist"

'

end if

'

End Sub
Any ideas on how to fix gratefully received.

Alexey admin 11/9/2006

Nigel,
please clarify what exactly happens.
Does it display error message ?

Show me it.
Or just silently does nothing ?

Or sends wrong email ?

N
NigelEtienne author 11/9/2006

Nigel,

please clarify what exactly happens.
Does it display error message ?

Show me it.
Or just silently does nothing ?

Or sends wrong email ?


Alexey

It just silently does nothing - the database is updated for the new record, it just fails to send an email to the persons manager. Is there a problem with the getrequestform statements?

Regards

Nigel

N
NigelEtienne author 11/10/2006



Alexey

It just silently does nothing - the database is updated for the new record, it just fails to send an email to the persons manager. Is there a problem with the getrequestform statements?

Regards

Nigel



I have just upgraded to 4.1.159 and can now send emails if I replace the email="name@co.uk"

all the other GetRequestForm fields are empty, it appears that the GetRequestForm statements are not being populated with the data input on the form.

Sergey Kornilov admin 11/10/2006

Nigel,
in new version you need to add value_ prefix before the field name when you call GetRequestForm.

email=GetRequestForm("value_EmailAddress")


In fact I recommend to use BeforeAdd events where you can use dict("fieldname") variables.