Hi,
I am using VB.net code and SQL server 2005.
I am havng below code for sending email in my vb.net code.
Protected Sub ibtnSendInvites_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ibtnSendInvites.Click
Try
Dim emailList As New List(Of String)
For Each curRow As GridViewRow In GridView1.Rows
Dim chkSelect As CheckBox = CType(curRow.Cells(1).FindControl("chkSelect"), CheckBox)
Dim emailLabel As Label = CType(curRow.Cells(1).FindControl("lblEmailAddress"), Label)
If chkSelect.Checked Then
emailList.Add(emailLabel.Text)
End If
Next
For Each email As String In emailList
Dim SelectDelegateMessage As String = "Please confirm your booking for this course"
Dim SelectDelegateSubject As String = "User-Point Course Booking Invitation Email"
Dim SelectDelegateFrom As String = WebConfigurationManager.AppSettings("UserPointEmailFromAddress").ToString()
SendEmail.SendMessage(SelectDelegateSubject, SelectDelegateMessage, SelectDelegateFrom, email, "")
Next
GridView1.DataBind()
Catch ex As Exception
'Throw New Exception("Cannot Insert Duplicate Record", ex)
End Try
End Sub
Now my problem is that some time if emailaddress is not valid or SMTP server is responding my application get hangs. I want to log my errors generated by my SMTP server in table or any log file it would be good if I can send back email to admin with the details of error occured.
Please suggest!
Thanks.
Best Regards, MS