Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 17th, 2006, 11:20 AM
Authorized User
 
Join Date: May 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Wondering how I'd go about doing this

I'm very new to ASP(as in first time ever using it) and I'm trying to create a page that will allow a person to email someone within our company.

Everything works fine and dandy, but when it comes to the comments section it just prints out as one large paragraph.

and what I need it to do is something that looks like this.

Line 1

Line 2
Line 3

I've tried putting in "<br><br> as it's a HTMLBody but doesn't seem to be doing the trick. What is my best way of doing this..

Thanks in advance.
 
Old July 17th, 2006, 05:38 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Use vbclf if its not an HTML type email. You can only use a <bR> if its an HTML email you arw sending

Wind is your friend
Matt
 
Old July 18th, 2006, 07:44 AM
Authorized User
 
Join Date: May 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well it is an HTML email that we are sending from the page, and what we're trying to get it is if the user enters in more then one paragraph that it doesn't get sent as one giant block of text. Here's the code for the actual scripting.


Code:
<%@ Language=VBScript %>
<%  'Written By - JR %>
<%
    Dim Mailer
    Dim iConf
    Dim Flds

    webaddr=Request.QueryString("pageref")
    'Check for missing fields
    Dim sCheckFailed
    'If Request.Form("emto") = "" then sCheckFailed = sCheckFailed & "0FN"
    'If Request.Form("emfrom") = "" then sCheckFailed = sCheckFailed & "0LN"

    'If sCheckFailed <> "" then Response.Redirect(Request.Form("Page") & "?rem=" & sCheckFailed & "&" & Request.Form)

    'Check for valid email address

        '-- contains a @
    EmailValid3 = false
    For x = 1 to Len(Request.Form("emfrom")) 
        If mid(Request.Form("emfrom"),x,1) = "@" Then
            EmailValid3 = true
        End If
    Next

    '-- contains a .
    EmailValid4 = false
    For x = 1 to Len(Request.Form("emfrom")) 
        If mid(Request.Form("emfrom"),x,1) = "." Then
            EmailValid4 = true
        End If
    Next



    If EmailValid3 = False OR EmailValid4 = False Then
        'Response.Redirect(Request.Form("Page") & "?rem=0EM&" & Request.Form)
        Response.Redirect(webaddr)
        SubmitEmail="[email protected]"
    else

    'All is good send the email

    Set Mailer = Server.CreateObject("CDO.Message")
    Set iConf = CreateObject("CDO.Configuration")
    Set Flds = iConf.Fields

    Flds("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1

    '**** Path below may need to be changed if it is not correct
    'Flds("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:\inetpub\mailroot\pickup"
    'Flds.Update

    Set Mailer.Configuration = iConf



    Mailer.From = Request.Form("emfrom")
    Mailer.to =   Request.Form("emto")
    Mailer.Subject = "Website Email"
    Mailer.HTMLBody =  Request.Form("emailComments") & "<br><br></br></br>" & _
    Request.Form("emname") & "<br><br></br></br>" & Request.Form("emphone")

    Mailer.Send

    Set mailer = Nothing
    Response.Redirect("/index.htm") 
    end if
    %>
 
Old July 18th, 2006, 12:38 PM
Registered User
 
Join Date: Jul 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

So, if a user enters a line break, you want to preserve it when the email is generated, right?

To do so, you need to convert Chr(13) to <BR> since you're sending an email using CDOSYS's .HTMLBody.

So, for example:

Code:
Dim strUserComments
strUserComments = Request.Form("emailComments")
If Len(strUserComments) > 1 Then
   strUserComments = Replace(strUserComments,Chr(13),"<br>")
End If
What this does is converts the carriage return character to the HTML <br> or line-break tag.

So, when calling objYourObject.HTMLBody = blah & strUserComments

the <br> will be included in the output email.




 
Old July 19th, 2006, 11:59 AM
Authorized User
 
Join Date: May 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

So using the above it should look something like this then?

Mailer.HTMLBody = Request.Form("emailComments") & strUserComments

Cause if that's the case then it's not adding in the hard-return..:(
 
Old July 19th, 2006, 12:16 PM
Authorized User
 
Join Date: May 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

nvm...got it..just forgot to remove something else that wasn't working

 
Old July 19th, 2006, 01:48 PM
Registered User
 
Join Date: Jul 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Did this do the trick then?

 
Old July 20th, 2006, 08:17 AM
Authorized User
 
Join Date: May 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yes it did thank you..

 
Old July 20th, 2006, 08:28 AM
Registered User
 
Join Date: Jul 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not a problem, glad to be of assistance. :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Wondering why .UDL for connecting string shailu BOOK: Beginning ASP 3.0 3 May 17th, 2005 07:39 AM
Chapter 5 page 150 - Wondering why.... potassium Beginning PHP 3 July 27th, 2003 12:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.