ASP.Net Environment.NewLine stops working half way through a script? - asp.net

I'm using a script to construct an email, and half way through the NewLines just quit working. I don't see any errors, nor do I can any when it's executed.
Here is the code:
message = message & "Zoning Selections -" & Environment.NewLine & Environment.NewLine
message = message & "Standard Report: " & Request.QueryString("chkList0") & Environment.NewLine
message = message & "Summary Zoning Report: " & Request.QueryString("chkList1") & Environment.NewLine
message = message & "Executive Summary: " & Request.QueryString("chkList2") & Environment.NewLine
message = message & "ZIP Report: " & Request.QueryString("chkList3") & Environment.NewLine
message = message & "Custom Report - Individual Products: " & Request.QueryString("chkList4") & Environment.NewLine
message = message & "Certificate of Occupancy: " & Request.QueryString("chkList5") & Environment.NewLine
message = message & "Building Code Violation: " & Request.QueryString("chkList6") & Environment.NewLine
message = message & "Code Compliance Violation: " & Request.QueryString("chkList7") & Environment.NewLine
message = message & "Fire Code Violation: " & Request.QueryString("chkList8") & Environment.NewLine
message = message & "Saftey Code Violation: " & Request.QueryString("chkList9") & Environment.NewLine
message = message & "Condemnation Report: " & Request.QueryString("chkList10") & Environment.NewLine
message = message & "Property Use: " & Request.QueryString("property_use") & Environment.NewLine
and here is the output:
Zoning Selections -
Standard Report: yes
Summary Zoning Report: yes
Executive Summary: yes
ZIP Report: yes
Custom Report - Individual Products: yes Certificate of Occupancy: yes Building Code Violation: yes Code Compliance Violation: yes Fire Code Violation: yes Saftey Code Violation: yes Condemnation Report: yes Property Use: Office
As you can see, the NewLine works until half way through, and then it simply prints everything on the same line. (also, the other NewLines were added to the file at another time than the ones printing correctly)
What am I missing?
EDIT
Apparently the plain-text formating of an email break all Environment.NewLine line breaks for the rest of the email when it encounters a line longer than 40-50 character (I was using Outlook 2013).
My solution was simple, switch to HTML format and use tags for line breaks instead.

Related

On a command button, how to fix an export a fixed file format? Compile error: Syntax error

I have this VBA code, when I try to run it, it gives me "Compile error: Syntax error" as can be seen in the image. I don't know VBA, what should I do to make this code work?
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, filename:=path & "filename1 & " " & filename2 & " " & filename3 & " " & filename4 & " " & filename5 & " " & filename6 & ".pdf"
Application.DisplayAlerts = True
ActiveWorkbook.Saved = False
Application.Quit
End Sub

How to ensure I get current date in vb?

I have the following code:
Public Function UltimoIngreso() As Date
Try
UltimoIngreso = Now.Date 'I am not ALWAYS getting the current date and time
' --other lines of code
Catch ex As Exception
' An error has occured so display an error message.
ReportBDLog.ReportErrorBD(ex, Me.GetType.ToString & "." & "UltimoIngreso" & vbCrLf & "Message: " & ex.Message & vbCrLf & "Source: " & ex.Source & vbCrLf, System.Reflection.MethodBase.GetCurrentMethod.ToString)
End Try
End Function
Sometimes, but not always, I get "Object reference not set to an instance of an object."
How do I ensure that Function UltimoIngreso always returns current date and time?
What am I missing?
This Function is used in an asp.net App.

asp contact form not send to email

Hi im doing a ASP contact form and for some reason i keep getting this.
Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed
/confirmation.asp, line 10
800401f3
I think that theres something wrong with my SMTP, please any help would be grateful.
<%
DIM strEmail, strFirstName, strLastName, strSubject, strComments
strEmail = request.form("Email")
strFirstName = request.form("FirstName")
strLastName = request.form("LastName")
strSubject = request.form("Subject")
strComments = request.form("Comments")
DIM Mailer,strMsgHeader, qryItem, strMsgInfo
Set Mailer = Server.CreateObject("smtpout.secureserver.net")//this line might be wrong.
Mailer.FromName = "Web Designs"
Mailer.FromAddress= "carlos#example.net"
Mailer.ReplyTo = strEmail
Mailer.RemoteHost = "mail.example.net"
Mailer.AddRecipient "", ""
Mailer.Subject = "Online Inquiry"
strMsgHeader = "This mail message was sent from the Online Form" & vbCrLf & vbCrLf
Mailer.BodyText = strMsgHeader & vbCrLf & "Email: " & Request.Form("Email") & _
vbCrLf & "First Name: " & Request.Form("FirstName") & _
vbCrLf & "Last Name: " & Request.Form("LastName") & _
vbCrLf & "Subject: " & Request.Form("Subject") & _
vbCrLf & "Comments: " & Request.Form("Comments")
IF Mailer.SendMail THEN
Response.Write strFirstName & ",<br>"
Response.Write "Your message has been successfully sent."
ELSE
Response.Write "The following error occurred while sending your message: " & Mailer.Response
END IF
%>
It seems you mix up the 'send email library' and your SMTP configuration.
the Mailer should look like
Set Mailer = Server.CreateObject("CDO.Message")
(although this could depend on your IIS version)
To configure your SMTP you should use this object:
Set cdoConfig = CreateObject("CDO.Configuration")
cdoConfig.Fields.Item(cdoSMTPServer) = "smtpout.secureserver.net"
Edit: example code: CDO Classic ASP form not working

Error 3704 Operation is not allowed when object is closed

I'm always getting error 3704. Operation is not allowed when object is closed.
Dim myConnection2, RSTitleList2
Set myConnection2 = CreateObject("ADODB.Connection")
Set RSTitleList2 = CreateObject("ADODB.Recordset")
myConnection2.Open "<%=connectionString%>"
sSQL1 = "Update FileInformation SET Status = 4 Where DataDefinitionID = 147 AND CustomerID = 71"
RSTitleList2.open sSQL1, myConnection2
if RSTitleList2.BOF and RSTitleList2.EOF then
msgbox("INSERT SUCCESSFUL")
frmProcess.cmdPublish.disabled = true
Else
msgbox("Not SUCCESSFUL")
msgbox(err.Number & " | " & err.description & " | " & err.Source)
End IF
msgbox(err.Number & " | " & err.description & " | " & err.Source)
It would help if you gave us the line where the line number which comes with the error message. However I can see one rather strange thing in your code
myConnection2.Open "<%=connectionString%>"
Why is "connectionstring" inside <%= %>. That syntax is used when you want display an asp variable within your html, eg
<h1>Welcome, <%= username %></h1>
When you're already in a block of asp code, just try
myConnection2.Open connectionString

Getting 'Type Mismatch' using hmac_sha1_js.asp in classic ASP

I am using the hex_sha1 function from the publicly available hmac_sha1_js.asp module.
In my ASP page, i have the directive to add the hmac_sha1 file, and i am calling the function like this:
Dim stringToHash
stringToHash = "11111111-2222-3333-4444-555555555555" & user.Fields.Item("REF").Value & "-" & Day(Now) & Month(Now) & Year(Now)
urlArgs = urlArgs & "&Fingerprint=" & hex_sha1(stringToHash)
But it is throwing a "Type Mismatch" error on the "urlArgs = " line.

Resources