Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.18 KB | None | 0 0
  1. Protected Sub SendMailBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SendMailBtn.Click  
  2.  
  3.     Dim dt As DataTable = DirectCast((RadioButtonList1.SelectedValue.Select(DataSourceSelectArguments.Empty)), DataView).Table  
  4.     For Each dr As DataRow In dt.Rows  
  5.         Dim emailsender As String = "noreply@mymailhost.com"  
  6.         Dim emailRecipient As String = dr("Email").ToString()  
  7.         Dim UserName As String = "Dear " + dr("UserName").ToString() + ",<br/><br/>"  
  8.         Dim mm As New MailMessage(emailsender, emailRecipient)  
  9.         mm.Subject = mailSubject.Text  
  10.         mm.Body = UserName + mailBody.Text  
  11.         mailBody.Text = Replace(mailBody.Text, vbCrLf, "<br />")  
  12.         mm.IsBodyHtml = True  
  13.         Dim smtp As New SmtpClient()  
  14.         smtp.Send(mm)  
  15.     Next  
  16.     Response.Redirect("/MailSuccess.aspx")  
  17.  
  18. End Sub  
  19.  
  20.  
  21. <asp:RadioButtonList ID="RadioButtonList1" runat="server">  
  22.        <asp:ListItem Value="sqldatasource1">Option 1</asp:ListItem>  
  23.        <asp:ListItem Value="sqldatasource2">Option 2</asp:ListItem>  
  24.        <asp:ListItem Value="sqldatasource3">Option 3</asp:ListItem>  
  25. </asp:RadioButtonList>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement