[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

ASP.net Email Errors

Asked by Albee_J in Programming for ASP.NET

Tags: Microsoft, Visual Studio, 2005, Asp.net, VB.net

I closed out a question. But failed to test the code fully.  I am sure it is 'my' syntax error and not the suggested code.  Can you please check the below code and see where I went wrong?  

The data is being inserted into the database, but the emails aren't sending.  (I've *** the emails for privacy reasons)
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
<script language="VB" runat="server">  
   
    Dim myConnection As Data.SqlClient.SqlConnection
    
    
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim rightNow As DateTime = DateTime.Now
        lblDateRequested.Text = String.Format("{0:d}", rightNow)
              
        myConnection = New Data.SqlClient.SqlConnection("Server=FMASQL;database=ITProjects;User ID=WebDept;Password=***")
        
       
        
    End Sub
    
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
       
        Dim Requestor As String
        Requestor = txtPreparedby.SelectedItem.ToString
        
        Dim PT As String = " <a href=""http://appserv1/ProjectTracker/ProjAdminAssign1.aspx"">Go to Project Tracker</a> "
        Dim myUserEmail As String = Requestor
        Dim myMessageSubject As String = "Your Project has been submitted"
        Dim BossMessageSubject As String = "A new project has been submitted"
        Dim eMailSent As Boolean
        Dim myBossEmail As String = "j****"
        Dim mySenderEMail As String = "webmaster***"
        
        Dim SendMessageBodyUser = "Your project was submitted!<br /><br/>  "
        SendMessageBodyUser += "<b>Form Information </b> "
        SendMessageBodyUser += "<b>Prepared by:</b>" & " " & txtPreparedby.SelectedItem.Text & " " + "<br /><br/>"
        SendMessageBodyUser += "<b>Project Title:</b> " & txtProjectTitle.Text & " " + "<br /><br/>"
        SendMessageBodyUser += "<b>Objective:</b>" & txtProjectObjective.Text & " " + "<br /><br/>"
        SendMessageBodyUser += "<b>Scope:</b>" & txtProjectScope.Text & " " + "<br /><br/>"
        SendMessageBodyUser += "<b>Justification:</b>" & txtProjectJustification.Text & " " + "<br /><br/>"
        SendMessageBodyUser += "<b>Requested Completion Date:</b>" & txtRequestedCompletionDate.Text & " " + "<br /><br/>"
        SendMessageBodyUser += "<b>Project Sponsors:</b><br /><br/>"
        SendMessageBodyUser += "<b>Specifications:</b>" & txtProjSpec.SelectedItem.Text & " " + "<br /><br/>"
        SendMessageBodyUser += "<b>Obstacles:</b>" & txtProjObst.SelectedItem.Text & " " + "<br /><br/>"
        SendMessageBodyUser += "<b>Testing:</b>" & txtProjTester.SelectedItem.Text & " " + "<br /><br/>"
        SendMessageBodyUser += "<b>Sign Off:</b>" & txtProjAccept.SelectedItem.Text & " " + "<br /><br/>"
        SendMessageBodyUser += "<b>File Location:</b>" & txtFileLocation.Text & " " + "<br /><br/>"
        
        Dim SendMessageBodyBoss = "A new project has been submitted!<br /><br/>  "
        SendMessageBodyBoss += "V***, a project needs to be assigned " + PT + "<br /><br/>"
        SendMessageBodyBoss += "<b>Form Information </b> "
        SendMessageBodyBoss += "<b>Prepared by:</b>" & " " & txtPreparedby.SelectedItem.Text & " " + "<br /><br/>"
        SendMessageBodyBoss += "<b>Project Title:</b> " & txtProjectTitle.Text & " " + "<br /><br/>"
        SendMessageBodyBoss += "<b>Objective:</b>" & txtProjectObjective.Text & " " + "<br /><br/>"
        SendMessageBodyBoss += "<b>Scope:</b>" & txtProjectScope.Text & " " + "<br /><br/>"
        SendMessageBodyBoss += "<b>Justification:</b>" & txtProjectJustification.Text & " " + "<br /><br/>"
        SendMessageBodyBoss += "<b>Requested Completion Date:</b>" & txtRequestedCompletionDate.Text & " " + "<br /><br/>"
        SendMessageBodyBoss += "<b>Project Sponsors:</b><br /><br/>"
        SendMessageBodyBoss += "<b>Specifications:</b>" & txtProjSpec.SelectedItem.Text & " " + "<br /><br/>"
        SendMessageBodyBoss += "<b>Obstacles:</b>" & txtProjObst.SelectedItem.Text & " " + "<br /><br/>"
        SendMessageBodyBoss += "<b>Testing:</b>" & txtProjTester.SelectedItem.Text & " " + "<br /><br/>"
        SendMessageBodyBoss += "<b>Sign Off:</b>" & txtProjAccept.SelectedItem.Text & " " + "<br /><br/>"
        SendMessageBodyBoss += "<b>File Location:</b>" & txtFileLocation.Text & " " + "<br /><br/>"
       
        'This will send message 1
        eMailSent = SendMail(myUserEmail, myMessageSubject, SendMessageBodyUser, mySenderEMail)
 
        If eMailSent = False Then
            'email was not sent escape
        End If
 
        'This will send message 2
        eMailSent = SendMail(myBossEmail, bossMessageSubject, SendMessageBodyBoss, mySenderEMail)
 
        If eMailSent = False Then
            'email was not sent escape
        End If    
 
   
        Try
    Dim insertProject As New Data.SqlClient.SqlCommand("INSERT INTO tblProjects (RequestorID,ProjectTitle,Objective,ProjectScope,ProjectJustification,RequestedCompletionDate,ProjSpec,ProjObst, ProjTester,ProjAccept,FileLocation,DateRequested,StatusID) VALUES (@RequestorID,@ProjectTitle, @Objective,@ProjectScope,@ProjectJustification,@RequestedCompletionDate,@ProjSpec,@ProjObst,@ProjTester,@ProjAccept, @FileLocation,@DateRequested,@StatusID);", myConnection)
            insertProject.Parameters.AddWithValue("@RequestorID", txtPreparedby.SelectedValue)
            insertProject.Parameters.AddWithValue("@ProjectTitle", txtProjectTitle.Text)
            insertProject.Parameters.AddWithValue("@Objective", txtProjectObjective.Text)
            insertProject.Parameters.AddWithValue("@ProjectScope", txtProjectScope.Text)
            insertProject.Parameters.AddWithValue("@ProjectJustification", txtProjectJustification.Text)
            insertProject.Parameters.AddWithValue("@RequestedCompletionDate", txtRequestedCompletionDate.Text)
            insertProject.Parameters.AddWithValue("@ProjSpec", txtProjSpec.SelectedValue)
            insertProject.Parameters.AddWithValue("@ProjObst", txtProjObst.SelectedValue)
            insertProject.Parameters.AddWithValue("@ProjTester", txtProjTester.SelectedValue)
            insertProject.Parameters.AddWithValue("@ProjAccept", txtProjAccept.SelectedValue)
            insertProject.Parameters.AddWithValue("@FileLocation", txtFileLocation.Text)
            insertProject.Parameters.AddWithValue("@DateRequested", lblDateRequested.Text)
            insertProject.Parameters.AddWithValue("@StatusID", 6)
        
      
            myConnection.Open()
            insertProject.ExecuteNonQuery()
            myConnection.Close()
            
        Catch ex As Exception
            lblResponse.Text = "Error saving: " & ex.Message.ToString
        End Try
        lblResponse.Text = "Your Project has been submitted"
        
   
    End Sub
    Function SendMail(ByVal toEmailId, ByVal messagesubject, ByVal sendBody, ByVal sendFrom)
        Dim mail As New MailMessage()
       
        Try
            'your email sending code
            'Set the priority - options are High, Low, and Normal
            mail.Priority = MailPriority.High
        
            'send the message
            Dim smtp As New SmtpClient("192.168.0.37")
            smtp.Send(Mail)
            Return True 'all worked fine
        Catch
            Return False 'something went wrong
        Finally
        End Try
    
    End Function
 
   </script>
 
Related Solutions
Keywords: ASP.net Email Errors
 
Loading Advertisement...
 
[+][-]02/22/08 08:46 AM, ID: 20959084Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/22/08 09:03 AM, ID: 20959272Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/22/08 09:10 AM, ID: 20959335Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/22/08 09:10 AM, ID: 20959341Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/22/08 09:17 AM, ID: 20959400Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/22/08 09:25 AM, ID: 20959470Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/22/08 09:30 AM, ID: 20959505Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/22/08 10:01 AM, ID: 20959748Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/22/08 10:07 AM, ID: 20959795Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/22/08 10:46 AM, ID: 20960139Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Programming for ASP.NET
Tags: Microsoft, Visual Studio, 2005, Asp.net, VB.net
Sign Up Now!
Solution Provided By: Mk3890
Participating Experts: 3
Solution Grade: B
 
[+][-]02/22/08 11:28 AM, ID: 20960533Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/22/08 11:56 AM, ID: 20960818Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/22/08 12:02 PM, ID: 20960883Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/22/08 12:04 PM, ID: 20960897Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/22/08 12:14 PM, ID: 20960983Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/22/08 02:45 PM, ID: 20962321Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/25/08 06:51 AM, ID: 20975778Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 / EE_QW_2_20070628