Hi,
I wrote some code that sends emails and inserts a table cell from GridView.
That code worked, and the email was successfully sent.
After that, I have added an image button to the last column in the GridView.
Please suggest the above code for sending emails without the last column of image buttons.
Thanking You,
samsmuthu
Protected Sub SendRequestMail()
Dim tryCount As Integer = 5
Dim failed As Boolean = False
Do
Try
failed = False
Dim ToMailIDs As String
ToMailIDs = LblRecipients.Text
Using sw As New StringWriter()
Using hw As New HtmlTextWriter(sw)
GridView1.RenderControl(hw)
Dim sr As New StringReader(sw.ToString())
Dim smtpSection As SmtpSection = CType(ConfigurationManager.GetSection("system.net/mailSettings/smtp"), SmtpSection)
Dim mm As MailMessage = New MailMessage()
mm.From = New MailAddress(smtpSection.From, "Notification")
For i As Integer = 0 To ToMailIDs.Split(","c).Length - 1
mm.To.Add(New MailAddress(ToMailIDs.Split(","c)(i)))
Next
mm.ReplyTo = New MailAddress("xxxxx@xxxxx.xxx")
mm.Subject = LblMrNumFull.Text & " | " & LblMrDate1x.Text & " | " & LblStorsName1.Text & " - Approval"
mm.Body = LblMrNumFull.Text & " | " & LblMrDate1x.Text & " | " & LblStorsName1.Text
mm.Body += sw.ToString()
mm.Body += "<br />"
mm.Body += "Thanking you"
mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
mm.DeliveryNotificationOptions = DeliveryNotificationOptions.Delay
mm.Headers.Add("Disposition-Notification-To", "yyyyyy@xxxxx.xxx")
' ----- webconfig mail start
mm.IsBodyHtml = True
Dim smtp As SmtpClient = New SmtpClient
smtp.Host = smtpSection.Network.Host
smtp.EnableSsl = smtpSection.Network.EnableSsl
Dim networkCred As NetworkCredential = New NetworkCredential(smtpSection.Network.UserName, smtpSection.Network.Password)
smtp.UseDefaultCredentials = smtpSection.Network.DefaultCredentials
smtp.Credentials = networkCred
smtp.Port = smtpSection.Network.Port
smtp.Send(mm)
' ----- webconfig mail end
End Using
End Using
Catch ex As Exception
failed = True
tryCount = tryCount - 1
Finally
Response.Redirect("~/abc/xyx.aspx?NewID=" & Request.QueryString("NewID"))
End Try
Loop While failed AndAlso tryCount > 0
End Sub