p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Basics (http://p2p.wrox.com/forumdisplay.php?f=61)
-   -   Wondering how I'd go about doing this (http://p2p.wrox.com/showthread.php?t=45321)

Smythe July 17th, 2006 11:20 AM

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.

mat41 July 17th, 2006 05:38 PM

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

Smythe July 18th, 2006 07:44 AM

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="jwright@septimatech.com"
    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
    %>


buellja July 18th, 2006 12:38 PM

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.





Smythe July 19th, 2006 11:59 AM

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..:(

Smythe July 19th, 2006 12:16 PM

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


buellja July 19th, 2006 01:48 PM

Did this do the trick then?


Smythe July 20th, 2006 08:17 AM

yes it did thank you..


buellja July 20th, 2006 08:28 AM

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



All times are GMT -4. The time now is 06:10 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.