I have a form that contains a checkboxlist. Based on the selection made on that checkbox list and once the user submits the form I have to send an email based on the selected topic. for each topic i have a person that needs to be receiving this email.
<tr>
<td class="NavyBold">Choose a Category:</td>
<td><asp:checkboxlist id="chksubtest" Runat="server" RepeatDirection="Vertical" RepeatColumns="2" AutoPostBack="false">
<asp:ListItem Value="Europe"></asp:ListItem>
<asp:ListItem Value="Australia"></asp:ListItem>
<asp:ListItem Value="North America"></asp:ListItem>
<asp:ListItem Value="Central America"></asp:ListItem>
<asp:ListItem Value="South America"></asp:ListItem>
<asp:ListItem Value="Asia"></asp:ListItem>
</asp:checkboxlist></td>
</tr>
I have decided to use select case. I tested the email and selected a topic but no email is being sent. Can someone take a look at this and let me know if I need to add anything else? or have a better suggestions.
thanks in advance....!
Here is the logic for my code....
Public Sub SendAMessage(ByVal chksubtest As String)
Dim Message As MailMessage = New MailMessage
Message.From = "post@test.net"
Select Case chksubtest
Case "Europe" : Message.To = "test1@test.net"
Message.Subject = "Europe"
Message.Body = "There is a new Europe Form that was submitted. Please click on the following link Try
SmtpMail.SmtpServer = "TESTC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
Case "Asia" : Message.To = "test2@test.net"
Message.Subject = "Asia"
Message.Body = "There is a new Asia Form that was submitted. Please click on the following link
Try
SmtpMail.SmtpServer = "TESTC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
Case "North America" : Message.To = "test3@test.net"
Message.Subject = "North America"
Message.Body = "There is a new North AmericaForm that was submitted. Please click on the following link
Try
SmtpMail.SmtpServer = "TESTC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
Case "Central America" : Message.To = "test4@test.net"
Message.Subject = "Central America"
Message.Body = "There is a new Central America Form that was submitted. Please click on the following link
Try
SmtpMail.SmtpServer = "TESTC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
Case "South America" : Message.To = "test5@test.net"
Message.Subject = "South America"
Message.Body = "There is a new South America Form that was submitted. Please click on the following link
Try
SmtpMail.SmtpServer = "TESTC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
Case "Australia" : Message.To = "test6@test.net"
Message.Subject = "Australia"
Message.Body = "There is a new Australia Form that was submitted. Please click on the following link
Try
SmtpMail.SmtpServer = "TESTC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
Case Else
Message.To = "test7@test.net"
Message.Subject = "New email from forms"
Try
SmtpMail.SmtpServer = "TESTC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
End Select
End Sub
<tr>
<td class="NavyBold">Choose a Category:</td>
<td><asp:checkboxlist id="chksubtest" Runat="server" RepeatDirection="Vertical" RepeatColumns="2" AutoPostBack="false">
<asp:ListItem Value="Europe"></asp:ListItem>
<asp:ListItem Value="Australia"></asp:ListItem>
<asp:ListItem Value="North America"></asp:ListItem>
<asp:ListItem Value="Central America"></asp:ListItem>
<asp:ListItem Value="South America"></asp:ListItem>
<asp:ListItem Value="Asia"></asp:ListItem>
</asp:checkboxlist></td>
</tr>
I have decided to use select case. I tested the email and selected a topic but no email is being sent. Can someone take a look at this and let me know if I need to add anything else? or have a better suggestions.
thanks in advance....!
Here is the logic for my code....
Public Sub SendAMessage(ByVal chksubtest As String)
Dim Message As MailMessage = New MailMessage
Message.From = "post@test.net"
Select Case chksubtest
Case "Europe" : Message.To = "test1@test.net"
Message.Subject = "Europe"
Message.Body = "There is a new Europe Form that was submitted. Please click on the following link Try
SmtpMail.SmtpServer = "TESTC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
Case "Asia" : Message.To = "test2@test.net"
Message.Subject = "Asia"
Message.Body = "There is a new Asia Form that was submitted. Please click on the following link
Try
SmtpMail.SmtpServer = "TESTC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
Case "North America" : Message.To = "test3@test.net"
Message.Subject = "North America"
Message.Body = "There is a new North AmericaForm that was submitted. Please click on the following link
Try
SmtpMail.SmtpServer = "TESTC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
Case "Central America" : Message.To = "test4@test.net"
Message.Subject = "Central America"
Message.Body = "There is a new Central America Form that was submitted. Please click on the following link
Try
SmtpMail.SmtpServer = "TESTC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
Case "South America" : Message.To = "test5@test.net"
Message.Subject = "South America"
Message.Body = "There is a new South America Form that was submitted. Please click on the following link
Try
SmtpMail.SmtpServer = "TESTC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
Case "Australia" : Message.To = "test6@test.net"
Message.Subject = "Australia"
Message.Body = "There is a new Australia Form that was submitted. Please click on the following link
Try
SmtpMail.SmtpServer = "TESTC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
Case Else
Message.To = "test7@test.net"
Message.Subject = "New email from forms"
Try
SmtpMail.SmtpServer = "TESTC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
End Select
End Sub