Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Registeration form

Status
Not open for further replies.

taree

Technical User
May 31, 2008
316
US
Hi all,

the registeraion form I created wroks fine in the development server and It does not work when I move it to production server. my guess is there might be some issues with receiving email....the production server might not be set up to send or accept email....could that be an issue. Please help thank you
 
Of course that can be a problem, but what exactly are the errors you are getting and what are you trying to do when you get them?
 
the registeraion form I created wroks fine in the development server and It does not work when I move it to production server.
You haven't provided any details.
my guess is there might be some issues with receiving email....the production server might not be set up to send or accept email....could that be an issue.
You tell us:) you have access to the servers to test this, we do not.

Does this problem occur on a test/staging box as well? (Not your dev machine, too many variances there.)
Does your app contain logging? if so what do the logs say?

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
here is th error message:

Exception information:
Exception type: SmtpException
Exception message: Failure sending mail.



Thread information:
Thread ID: 5
Thread account name: NT AUTHORITY\NETWORK SERVICE
Is impersonating: False
Stack trace: at System.Net.Mail.SmtpClient.Send(MailMessage message)
at registeration.SendMail(String toEmail, String fromEmail) in D:\Applications\bidlet\registeration.aspx.vb:line 41
at registeration.btnReg_Click(Object sender, EventArgs e) in D:\Applications\bidlet\registeration.aspx.vb:line 6
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


here is my code:

Protected Sub btnReg_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReg.Click
''''send message from visitor to me
SendMail("Bid.Letting@dot.state.mn.us", txtEmail.Text)
''''send message from you to visitor
SendMail(txtEmail.Text, "Bid.Letting@dot.state.mn.us")
End Sub
Private Sub SendMail(ByVal toEmail As String, ByVal fromEmail As String)
Dim objEmail As New MailMessage
objEmail.To.Add(toEmail)
objEmail.CC.Add(toEmail)
objEmail.From = New MailAddress(fromEmail)
Dim sMsg As System.String

Dim rcvdEmail As String = toEmail
If rcvdEmail = "Bid.Letting@dot.state.mn.us" Then
sMsg = "Your registeration has been recieved." & vbCrLf & "The results are as follows:" & vbCrLf
sMsg += "Email Address : " & txtEmail.Text & vbCrLf
sMsg += "Contact Person Name : " & txtVendor.Text & vbCrLf
sMsg += "Vendor Id : " & txtVendId.Text & vbCrLf
sMsg += "Phone Number : " & txtPhone.Text & vbCrLf
sMsg += "Fax Number : " & txtFax.Text & vbCrLf

If drpDistrict.SelectedValue = 0 Then
sMsg += "Closest District: " & "Duluth" & vbCrLf
ElseIf drpDistrict.SelectedValue = 1 Then
sMsg += "Closest District: " & "Bemigji" & vbCrLf
ElseIf drpDistrict.SelectedValue = 2 Then
sMsg += "Closest District: " & "Brainerd" & vbCrLf
ElseIf drpDistrict.SelectedValue = 3 Then
sMsg += "Closest District: " & "Detroit Lakes" & vbCrLf
ElseIf drpDistrict.SelectedValue = 4 Then
sMsg += "Closest District: " & "Metro" & vbCrLf
ElseIf drpDistrict.SelectedValue = 5 Then
sMsg += "Closest District: " & "Rochester" & vbCrLf
ElseIf drpDistrict.SelectedValue = 6 Then
sMsg += "Closest District: " & "Mankato" & vbCrLf
Else : drpDistrict.SelectedValue = 7
sMsg += "Closest District: " & "Willmar" & vbCrLf
End If

If rdYes.Checked = True Then
sMsg += "Could you be interested in attending Electronic Bid Submittal Training? " & "Yes"
Else
sMsg += "Could you be interested in attending Electronic Bid Submittal Training? " & "No"
End If

objEmail.Subject = "Training Registeration "
''''objEmail.Attachments.Add(New Attachment(AttachementFile.PostedFile.InputStream,
''''AttachementFile.FileName))
objEmail.Body = sMsg
objEmail.IsBodyHtml = False
Else
sMsg = "Please do not respond, this is an automated message to let" & vbCrLf
sMsg += "you know that your registeration has been received." & vbCrLf
sMsg += "We will take aproperiate action." & vbCrLf
sMsg += "Thank you," & vbCrLf
sMsg += "Mn/DOT, Office of Construction and Innovative Contracting "
objEmail.Subject = "Training Registeration confirmation"
objEmail.Body = sMsg
End If
Dim SmtpMail As New SmtpClient()
SmtpMail.Send(objEmail)
End Sub


 
this might be the problem:
Code:
objEmail.To.Add(toEmail)
objEmail.CC.Add(toEmail)
adding the recipient to both the to and carbon copy fields. how are you capturing the exception. if you just getting
Expection.Mesasge, Expection.Type you are missing the inner excpetion, if there is one. Use Exception.ToString() instead. this will capture the type, message, stacktrace and traverse inner exceptions.

there is also alot of room to improve readability of the code.

you may be able to replace
Code:
If drpDistrict.SelectedValue = 0 Then
                sMsg += "Closest District: " & "Duluth" & vbCrLf
            ElseIf drpDistrict.SelectedValue = 1 Then
                sMsg += "Closest District: " & "Bemigji" & vbCrLf
            ElseIf drpDistrict.SelectedValue = 2 Then
                sMsg += "Closest District: " & "Brainerd" & vbCrLf
            ElseIf drpDistrict.SelectedValue = 3 Then
                sMsg += "Closest District: " & "Detroit Lakes" & vbCrLf
            ElseIf drpDistrict.SelectedValue = 4 Then
                sMsg += "Closest District: " & "Metro" & vbCrLf
            ElseIf drpDistrict.SelectedValue = 5 Then
                sMsg += "Closest District: " & "Rochester" & vbCrLf
            ElseIf drpDistrict.SelectedValue = 6 Then
                sMsg += "Closest District: " & "Mankato" & vbCrLf
            Else : drpDistrict.SelectedValue = 7
                sMsg += "Closest District: " & "Willmar" & vbCrLf
            End If
with
Code:
sMsg += "Closest District: " & drpDistrict.SelectedItem.Text

also I would recommend using a StringBuilder rather than smgb+= througout the text. example:
Code:
Dim message as StringBuilder = new StringBuilder;
message.AppendFormat("Number: {0:N2}", 1)
message.AppendLine("hello")
message.Append(DateTime.Now)
would produce
[tt]
Number: 01hello
2008-8-22 11:10am[/tt]

with c# you can also write blocks of text like this
string s = @"hello
world";
and it will keep the formatting. not sure if vb has the same feature.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thank you Jason! I will let you knwo that outcome.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top