Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New Coder
    Join Date
    Mar 2005
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sending email - cdonts

    Hi all - Please could someone help me!

    I am trying to send email from an online form using cdonts. I have got a form that is filld in with the contact details and so on, but want to match a selected field form a drop down to a database field. I can get it to send the mail normally without the dbase connection but do not quite know where to start.

    I think I know what to do, just need a bit of help getting there. Here is the code:

    <%


    'Set the response buffer to true so we execute all asp code before sending the HTML to the clients browser
    Response.Buffer = True

    'Dimension variables
    Dim strBody 'Holds the body of the e-mail
    Dim objCDOMail 'Holds the mail server object
    Dim strMyEmailAddress 'Holds your e-mail address
    Dim strCCEmailAddress 'Holds any carbon copy e-mail addresses if you want to send carbon copies of the e-mail
    Dim strBCCEmailAddress 'Holds any blind copy e-mail addresses if you wish to send blind copies of the e-mail
    Dim strReturnEmailAddress 'Holds the return e-mail address of the user
    'Dimension Variables for the dbase conn?
    Dim adoCon 'Holds the Database Connection Object
    Dim rswedweb 'Holds the recordset for the records in the database
    Dim strSQL 'Holds the SQL query for the database
    Dim News

    'copied from default page - this is to set an active conn to the db to match the scname with mailad
    'Create an ADO connection object
    Set adoCon = Server.CreateObject("ADODB.Connection")

    'Set an active connection to the Connection object using a DSN-less connection
    adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("Wedweb.mdb")

    'Initialise the strSQL variable with an SQL statement to query the database
    strSQL = "select news.schoolcont FROM news;"

    'Open the recordset with the SQL query
    rswedweb.Open strSQL, adoCon



    'Open the recordset with the SQL query
    rswedweb.Open strSQL, adoCon


    Do While not rswedweb.EOF
    url = rswedweb("update")
    if Not IsNull(update) then %>




    '----------------- Place your e-mail address in the following sting ----------------------------------

    strMyEmailAddress = "myemailadd@hotmail.com"

    '----------- Place Carbon Copy e-mail address's in the following sting, separated by ; --------------

    strCCEmailAddress = "" 'Use this string only if you want to send the carbon copies of the e-mail

    '----------- Place Blind Copy e-mail address's in the following sting, separated by ; --------------

    strBCCEmailAddress = "" 'Use this string only if you want to send the blind copies of the e-mail

    '-----------------------------------------------------------------------------------------------------
    If

    'Read in the users e-mail address
    strReturnEmailAddress = Request.Form("email")


    'Initialse strBody string with the body of the e-mail
    strBody = "<h2>Helpdesk Call</h2>"
    strBody = strBody & "<br><b>Contact Name: </b>" & Request.Form("contactname") & " " & Request.Form("schoolName")
    strBody = strBody & "<br><br><b>School: -</b>"
    If (Request.Form("callDesc")) > "" Then
    strBody = strBody & "<br> " & Request.Form("CallDesc")
    End If
    If (Request.Form("town")) > "" Then
    strBody = strBody & "<br> " & Request.Form("town")
    End If
    If (Request.Form("county")) > "" Then
    strBody = strBody & "<br> " & Request.Form("county")
    End If
    If (Request.Form("schoolName")) > "--- Choose One ---" Then
    strBody = strBody & "<br> " & Request.Form("SchoolName")
    End IF

    strBody = strBody & "<br><b>E-mail: </b>" & strReturnEmailAddress
    'strBody = strBody & "<br><br><b>Enquiry: - </b><br>" & Replace(Request.Form("enquiry"), vbCrLf, "<br>")


    'Check to see if the user has entered an e-mail address and that it is a valid address otherwise set the e-mail address to your own otherwise the e-mail will be rejected
    If Len(strReturnEmailAddress) < 5 OR NOT Instr(1, strReturnEmailAddress, " ") = 0 OR InStr(1, strReturnEmailAddress, "@", 1) < 2 OR InStrRev(strReturnEmailAddress, ".") < InStr(1, strReturnEmailAddress, "@", 1) Then

    'Set the return e-mail address to your own
    strReturnEmailAddress = strMyEmailAddress
    End If


    'Send the e-mail

    'Create the e-mail server object
    Set objCDOMail = Server.CreateObject("CDONTS.NewMail")

    'Who the e-mail is from (this needs to have an e-mail address in it for the e-mail to be sent)
    objCDOMail.From = Request.Form("firstName") & " " & Request.Form("lastName") & " <" & strReturnEmailAddress & ">"

    'Who the e-mail is sent to
    objCDOMail.To = strMyEmailAddress

    'Who the carbon copies are sent to
    objCDOMail.Cc = strCCEmailAddress

    'Who the blind copies are sent to
    objCDOMail.Bcc = strBCCEmailAddress

    'Set the subject of the e-mail
    objCDOMail.Subject = "Contact"

    'Set the e-mail body format (0=HTML 1=Text)
    objCDOMail.BodyFormat = 0

    'Set the mail format (0=MIME 1=Text)
    objCDOMail.MailFormat = 0

    'Set the main body of the e-mail
    objCDOMail.Body = strBody

    'Importance of the e-mail (0=Low, 1=Normal, 2=High)
    objCDOMail.Importance = 1

    'Send the e-mail
    objCDOMail.Send

    'Close the server object
    Set objCDOMail = Nothing
    %>
    <html>
    <head>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <title></title>



    Any ideas?

    Thanks
    Last edited by Seanus; 04-13-2006 at 01:15 PM.

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    Do While not rswedweb.EOF 
    url = rswedweb("update")
    if Not IsNull(update) then %>
    What is this?

    You need to close your IF and do a Loop

    Code:
    <%
    
    
    'Set the response buffer to true so we execute all asp code before sending the HTML to the clients browser
    Response.Buffer = True
    
    'Dimension variables
    Dim strBody 'Holds the body of the e-mail
    Dim objCDOMail 'Holds the mail server object
    Dim strMyEmailAddress 'Holds your e-mail address
    Dim strCCEmailAddress 'Holds any carbon copy e-mail addresses if you want to send carbon copies of the e-mail
    Dim strBCCEmailAddress 'Holds any blind copy e-mail addresses if you wish to send blind copies of the e-mail
    Dim strReturnEmailAddress 'Holds the return e-mail address of the user
    'Dimension Variables for the dbase conn?
    Dim adoCon 'Holds the Database Connection Object
    Dim rswedweb 'Holds the recordset for the records in the database
    Dim strSQL 'Holds the SQL query for the database
    Dim News
    
    'copied from default page - this is to set an active conn to the db to match the scname with mailad
    'Create an ADO connection object 
    Set adoCon = Server.CreateObject("ADODB.Connection") 
    
    'Set an active connection to the Connection object using a DSN-less connection 
    adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("Wedweb.mdb") 
    
    'Initialise the strSQL variable with an SQL statement to query the database 
    strSQL = "select news.schoolcont FROM news;"
    
    'Open the recordset with the SQL query 
    rswedweb.Open strSQL, adoCon 
    
    
    Do While Not rswedweb.EOF 
    	url = rswedweb("update")
    	
    	If Not IsNull(url) then
    
    	'----------------- Place your e-mail address in the following sting ----------------------------------
    	
    	strMyEmailAddress = "myemailadd@hotmail.com"
    	
    	'----------- Place Carbon Copy e-mail address's in the following sting, separated by ; --------------
    	
    	strCCEmailAddress = "" 'Use this string only if you want to send the carbon copies of the e-mail
    	
    	'----------- Place Blind Copy e-mail address's in the following sting, separated by ; --------------
    	
    	strBCCEmailAddress = "" 'Use this string only if you want to send the blind copies of the e-mail
    	
    	'-----------------------------------------------------------------------------------------------------
    	
    	
    	'Read in the users e-mail address
    	strReturnEmailAddress = Request.Form("email")
    	
    	
    	'Initialse strBody string with the body of the e-mail
    	strBody = "<h2>Helpdesk Call</h2>"
    	strBody = strBody & "<br><b>Contact Name: </b>" & Request.Form("contactname") & " " & Request.Form("schoolName")
    	strBody = strBody & "<br><br><b>School: -</b>"
    	
    		If (Request.Form("callDesc")) > "" Then 
    			strBody = strBody & "<br> " & Request.Form("CallDesc")
    		End If
    		
    		If (Request.Form("town")) > "" Then 
    			strBody = strBody & "<br> " & Request.Form("town")
    		End If
    		
    		If (Request.Form("county")) > "" Then 
    			strBody = strBody & "<br> " & Request.Form("county")
    		End If
    		
    		If (Request.Form("schoolName")) > "--- Choose One ---" Then
    			strBody = strBody & "<br> " & Request.Form("SchoolName")
    		End IF
    		
    		strBody = strBody & "<br><b>E-mail: </b>" & strReturnEmailAddress
    		'strBody = strBody & "<br><br><b>Enquiry: - </b><br>" & Replace(Request.Form("enquiry"), vbCrLf, "<br>")
    		
    		
    		'Check to see if the user has entered an e-mail address and that it is a valid address otherwise set the e-mail address to your own otherwise the e-mail will be rejected
    		If Len(strReturnEmailAddress) < 5 OR NOT Instr(1, strReturnEmailAddress, " ") = 0 OR InStr(1, strReturnEmailAddress, "@", 1) < 2 OR InStrRev(strReturnEmailAddress, ".") < InStr(1, strReturnEmailAddress, "@", 1) Then
    			'Set the return e-mail address to your own
    			strReturnEmailAddress = strMyEmailAddress
    		End If 
    	
    	
    		'Send the e-mail
    		
    		'Create the e-mail server object
    		Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
    		
    		'Who the e-mail is from (this needs to have an e-mail address in it for the e-mail to be sent)
    		objCDOMail.From = Request.Form("firstName") & " " & Request.Form("lastName") & " <" & strReturnEmailAddress & ">"
    		
    		'Who the e-mail is sent to
    		objCDOMail.To = strMyEmailAddress
    		
    		'Who the carbon copies are sent to
    		objCDOMail.Cc = strCCEmailAddress
    		
    		'Who the blind copies are sent to
    		objCDOMail.Bcc = strBCCEmailAddress
    		
    		'Set the subject of the e-mail
    		objCDOMail.Subject = "Contact"
    		
    		'Set the e-mail body format (0=HTML 1=Text)
    		objCDOMail.BodyFormat = 0
    		
    		'Set the mail format (0=MIME 1=Text)
    		objCDOMail.MailFormat = 0
    		
    		'Set the main body of the e-mail
    		objCDOMail.Body = strBody
    		
    		'Importance of the e-mail (0=Low, 1=Normal, 2=High)
    		objCDOMail.Importance = 1 
    		
    		'Send the e-mail
    		objCDOMail.Send
    		
    		'Close the server object
    		Set objCDOMail = Nothing
    	End If
    Loop
    %>

  • #3
    New Coder
    Join Date
    Mar 2005
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok - I have taken it all out and think that I may be nearer to the problem. I have a form page with the following option detail in the drop down which I am trying to read in from the asp page which sends the email. Please could you tell me how to read in the option value of the drop down menu.

    Form page:
    <option value="<%rswedweb("email")%>"><%=rswedweb("schoolname")%></option>

    now what I need to do is read the "email" bit in only from the page that sends the email for the return email address - cold you help me with this. I hope it is going to go something like this ( strReturnEmailAddress is already defined):

    strReturnEmailAddress = request.form("schoolname") option value="<%=rswedweb("email")%>


    Thanks!
    Last edited by Seanus; 04-26-2006 at 11:47 AM.

  • #4
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Too much there to look through. If you want help from members then it's probably best to post a specific code snippet that you are having problems with.

    http://www.w3schools.com/vbscript/vb..._functions.asp
    http://www.w3schools.com/asp/default.asp

  • #5
    New Coder
    Join Date
    Mar 2005
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I know it is a lot and beleive me - if I knew which bit was the problem I would paste it in. Do you know of any site where I can get a command reference for ASP to help me determine which bit is giving me the problem. I had a look last night and it just seem like the send_email.asp is not reading in the email address from the form when the schoolname is selected.

    Sorry for the long code and thanks for the help.

  • #6
    New Coder
    Join Date
    Mar 2005
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think I have found where the problem is - now please could I have some help fixing it - I would be really greatfull.

    Form page:
    <option value="<%rswedweb("email")%>"><%=rswedweb("schoolname")%></option>

    now what I need to do is read the "email" bit in only from the page that sends the email for the return email address - cold you help me with this. I hope it is going to go something like this ( strReturnEmailAddress is already defined):

    strReturnEmailAddress = request.form("schoolname") option value="<%=rswedweb("email")%>


    Thanks!
    Last edited by Seanus; 04-27-2006 at 09:18 AM.

  • #7
    New Coder
    Join Date
    Mar 2005
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Please Help?

    Hi guys, I am still trying to sort this one out - does anyone have any ideas? I think I have found the problem (above).

    Thanks

  • #8
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Right. I'm a bit confused by all this, so let me get it straight.

    1. You've got a database table that lists... schools, or something. Each school has an email address.
    2. You've got a contact form that lets people type in their email address, but you want to change that.
    3. You want to populate a <select> box on the contact form, with a list of schools; the user then selects a school, fills in the rest of the form and, when they hit 'Send', their email address is automatically passed to the bit of code that sends the email to you.

    Is that about right?

    Firstly, I'm confused by this bit:

    Code:
    strSQL = "select news.schoolcont FROM news;"
    rswedweb.Open strSQL, adoCon
    That gives you a recordset called "rswedweb", with one column: "schoolcont". But nowhere in your code do you refer to rswedweb.Fields("schoolcont"). You do, however, refer to quite a few other things. I'm not sure where they're supposed to be coming from, but I probably wouldn't rely on them being what you expect them to be. Like url = rswedweb("update") - that recordset doesn't have a field called "update". What value are you hoping to get in your "url" variable?

    There are a few other errors in the code you posted: you've got a closing ASP script tag after if Not IsNull(update) then, and you're opening your recordset twice.

    Other than that... well, you're not impossibly far off. Although it still doesn't make a lot of sense. You say "I have taken it all out" after the amendments that degsy posted; could you post the exact code that you're now working with? Post all of it - just wrap it in CODE tags so it's a bit more readable.

  • #9
    New Coder
    Join Date
    Mar 2005
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the reply I have been messing with it all so much now that I don't even know what is going on. You are correct in what you said in your response. I have been copying and pasting from various bits of code so i think I have left some stuff in that does not need to be there. I am using two pages to try achieve sending an email.

    This is the code I am currently using on the form where they select the schoolname, enter their contact name and a call description:

    Code:
     <%
    'Dimension variables
    Dim adoCon          'Holds the Database Connection Object
    Dim rswedweb    'Holds the recordset for the records in the database
    Dim strSQL           'Holds the SQL query for the database
    Dim schoolcont
    
    'Create an ADO connection object 
    Set adoCon = Server.CreateObject("ADODB.Connection") 
    
    'Set an active connection to the Connection object using a DSN-less connection 
    adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("Wedweb.mdb") 
    
    'Create an ADO recordset object 
    Set rswedweb = Server.CreateObject("ADODB.Recordset") 
    
    'Initialise the strSQL variable with an SQL statement to query the database 
    strSQL = "select schoolcont.schoolname, schoolcont.email FROM schoolcont ORDER BY schoolname"
    'strSQL = "select schoolcont.schoolname, schoolcont.supported, schoolcont.Email FROM schoolcont where schoolcont.supported = 'Y' ORDER BY schoolname"
    'strSQL = "select * FROM schoolcont"
    
    'Open the recordset with the SQL query 
    rswedweb.Open strSQL, adoCon 
    
    Do While not rswedweb.EOF 
     schoolname = rswedweb("schoolname")
     if Not IsNull(schoolname) then %>
      
    				  
    <%end if%>
    		<option value="<%=rswedweb("Email")%>"><%=rswedweb("schoolname")%></option> 
    		<%rswedweb.MoveNext
    		Loop
      	
    		
    
    'Reset server objects 
    rswedweb.Close 
    Set rswedweb = Nothing 
    Set adoCon = Nothing 
    %>
    </select>
    </form>
    </td>
    </td>
    and this is the page that I am using to send the email:
    Code:
    <%
    
    
    'Set the response buffer to true so we execute all asp code before sending the HTML to the clients browser
    Response.Buffer = True
    
    'Dimension variables
    Dim strBody 			'Holds the body of the e-mail
    Dim objCDOMail 			'Holds the mail server object
    Dim strMyEmailAddress 		'Holds your e-mail address
    Dim strCCEmailAddress		'Holds any carbon copy e-mail addresses if you want to send carbon copies of the e-mail
    Dim strBCCEmailAddress		'Holds any blind copy e-mail addresses if you wish to send blind copies of the e-mail
    Dim strReturnEmailAddress	'Holds the return e-mail address of the user
    'Dimension Variables for the dbase conn
    Dim adoCon          'Holds the Database Connection Object
    Dim rswedweb    'Holds the recordset for the records in the database
    Dim strSQL           'Holds the SQL query for the database
    Dim News
    
    
    'Create an ADO connection object 
    Set adoCon = Server.CreateObject("ADODB.Connection") 
    
    'Set an active connection to the Connection object using a DSN-less connection 
    adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("Wedweb.mdb") 
    
    'Create an ADO recordset object 
    Set rswedweb = Server.CreateObject("ADODB.Recordset") 
    
    'Initialise the strSQL variable with an SQL statement to query the database 
    strSQL = "select schoolcont.schoolname, schoolcont.email FROM schoolcont ORDER BY schoolname"
    'strSQL = "select schoolcont.schoolname, schoolcont.supported, schoolcont.email FROM schoolcont where schoolcont.supported = 'Y' ORDER BY schoolname"
    'strSQL = "select * FROM schoolcont"
    
    'Open the recordset with the SQL query 
    rswedweb.Open strSQL, adoCon 
    
    Do While not rswedweb.EOF 
     schoolname = rswedweb("schoolname")
     if Not IsNull(schoolname) then 
      
    				  
    end if
     
    
    '----------------- Place your e-mail address in the following sting ----------------------------------
    
    strMyEmailAddress = "myemail@dads-haven.co.uk"
    
    '----------- Place Carbon Copy e-mail address's in the following sting, separated by ; --------------
    
    'strCCEmailAddress = "" 'Use this string only if you want to send the carbon copies of the e-mail
    
    '----------- Place Blind Copy e-mail address's in the following sting, separated  by ; --------------
    
    'strBCCEmailAddress = "" 'Use this string only if you want to send the blind copies of the e-mail
    
    '-----------------------------------------------------------------------------------------------------
    
    
    'Read in the users e-mail address
    strReturnEmailAddress = request.form("schoolname")option value="<%=rswedweb ("Email")%> 
    
    <%
    'Initialse strBody string with the body of the e-mail
    strBody = "<h2>Helpdesk Call</h2>"
    strBody = strBody & "<br><b>Contact Name: </b>" & Request.Form("contactname")& "" & request.form ("schoolname")
    
    strBody = strBody & "<br><br><b>School: -</b>"
    If (Request.Form("callDesc")) > "" Then strBody = strBody & "<br>  " & Request.Form("CallDesc")
    
    
    
    If (Request.Form("schoolName")) > "" Then strBody = strBody & "<br>  " & Request.Form("SchoolName")
    
    
    
    strBody = strBody & "<br><b>E-mail: </b>" & strReturnEmailAddress
    'strBody = strBody & "<br><br><b>Enquiry: - </b><br>" & Replace(Request.Form("enquiry"), vbCrLf, "<br>")
    
    
    'Check to see if the user has entered an e-mail address and that it is a valid address otherwise set the e-mail address to your own otherwise the e-mail will be rejected
    If Len(strReturnEmailAddress) < 5 OR NOT Instr(1, strReturnEmailAddress, " ") = 0 OR InStr(1, strReturnEmailAddress, "@", 1) < 2 OR InStrRev(strReturnEmailAddress, ".") < InStr(1, strReturnEmailAddress, "@", 1) Then
    	
    	'Set the return e-mail address to your own
    strReturnEmailAddress = strMyEmailAddress
    
    
    
    
    'Send the e-mail
    
    'Create the e-mail server object
    Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
    
    'Who the e-mail is from (this needs to have an e-mail address in it for the e-mail to be sent)
    objCDOMail.From = Request.Form("ContactName") & " <" & strReturnEmailAddress & ">"
    
    'Who the e-mail is sent to
    objCDOMail.To = strMyEmailAddress
    
    'Set the subject of the e-mail
    objCDOMail.Subject = "Online Helpdesk Call"
    
    'Set the e-mail body format (0=HTML 1=Text)
    objCDOMail.BodyFormat = 0
    
    'Set the mail format (0=MIME 1=Text)
    objCDOMail.MailFormat = 0
    
    'Set the main body of the e-mail
    objCDOMail.Body = strBody
    
    'Importance of the e-mail (0=Low, 1=Normal, 2=High)
    objCDOMail.Importance = 1 
    
    'Send the e-mail
    objCDOMail.Send
    	
    'Close the server object
    Set objCDOMail = Nothing
    
    End If
    Loop
    %>
    I know there is a lot of code here - sorry. url is

    http://www.dads-haven.co.uk/wedict/calllog.asp

    If you want to see what the form looks like

    thanks -

    Sean

  • #10
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Ok, sorry for the delay.

    You're pretty close, but yeah there's a load of cr4p in there that you don't need. I've stripped it out (as well as all the comments, for berevity) and (hopefully) sorted out any typo's:


    Populate the <select> box with a list of schools:
    Code:
    <%
    Set adoCon = Server.CreateObject("ADODB.Connection") 
    adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("Wedweb.mdb") 
    Set rswedweb = Server.CreateObject("ADODB.Recordset") 
    strSQL = "select schoolname, email FROM schoolcont ORDER BY schoolname"
    rswedweb.Open strSQL, adoCon 
    %>
    
    <select name="schoolname" id="schoolname">
    <%
    Do While not rswedweb.EOF 
    	schoolname = rswedweb("schoolname")
    	if Not IsNull(schoolname) then
    %>
    	<option value="<%=rswedweb("Email")%>"><%=rswedweb("schoolname")%></option>
    <%
    	end if
    	rswedweb.MoveNext
    Loop
    %>
    </select>
    
    <%
    rswedweb.Close 
    Set rswedweb = Nothing 
    adoCon.Close
    Set adoCon = Nothing 
    %>

    Grab the selected school's email address and drop it into the "From" email field:
    Code:
    <%
    strMyEmailAddress = "myemail@dads-haven.co.uk"
    strReturnEmailAddress = request.form("schoolname")
    
    strBody = "<h2>Helpdesk Call</h2>"
    strBody = strBody & "<br><b>Contact Name: </b>" & Request.Form("contactname")& "" & request.form ("schoolname")
    strBody = strBody & "<br><br><b>School: -</b>"
    If (Request.Form("callDesc")) > "" Then strBody = strBody & "<br>  " & Request.Form("CallDesc")
    If (Request.Form("schoolName")) > "" Then strBody = strBody & "<br>  " & Request.Form("SchoolName")
    strBody = strBody & "<br><b>E-mail: </b>" & strReturnEmailAddress
    
    Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
    objCDOMail.From = Request.Form("ContactName") & " <" & strReturnEmailAddress & ">"
    objCDOMail.To = strMyEmailAddress
    objCDOMail.Subject = "Online Helpdesk Call"
    objCDOMail.BodyFormat = 0
    objCDOMail.MailFormat = 0
    objCDOMail.Body = strBody
    objCDOMail.Importance = 1 
    objCDOMail.Send
    Set objCDOMail = Nothing
    
    %>

    I gotta run, I'll post more detail / explain if you need it later on.

    Hope that helps some, anyway.

  • #11
    New Coder
    Join Date
    Mar 2005
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    IT WORKS! - I am eternally greatful! You are a life saver. I can not beleive how much rubbish I had in there. Thanks for your help.


  • #12
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    No worries

    I'm not implying that you would, but I should add that simply copying and pasting code that you've got off these boards isn't going to do anyone, least of all you, any good. Neither am I suggesting that the stuff I posted up above is a shining example of good code, but: read through it. Make sure you understand exactly what each line does; compare it to what you had and work out for yourself why I've changed bits. And then go and improve on it: one thing I didn't change was the looping through a recordset, because I'm a lazy bugger But you should use getRows() instead.

    Anyway - I apologise if that sounded condescending, I don't mean it to. Good luck


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •