Imar,
I'm stuck again...
I wanted to handle the exception generated if/when there is a problem with the mail server as depicted in your 3.5 book to the file share app but ran into a problem.
The file share uses a
VB standalone program not an aspx code behind.
File share uses this method for diplaying a successful mail sent;
ASPX
VB
Code:
'send an email to the recipient...
Utilities.SendEmail(txtRecipientEmail.Text, _
txtSenderEmail.Text, Config.EmailSubject, emailBody)
Server.Transfer("UploadComplete.aspx", True)
The above UploadComplete.aspx is a page that says 'message sent' and notice how he uses the Server.Transfer to display the page.
So in the interest of not rewriting the file share I figured I could use the same system and mad an UploadIncomplete.aspx that says 'message not sent', but when I created the Try, Catch in the standalone
VB I discovered that Server.Transfer does not work.
VB
Code:
''' <summary>
''' SendEmail is used to send an email with the established settings and parameters
''' </summary>
Public Shared Sub SendEmail(ByVal MsgTo As String, ByVal MsgFrom As String, ByVal MsgSubject As String, ByVal MsgText As String)
Dim SmtpSettings As MailSettings
SmtpSettings = GetSmtpSettings()
Dim SmtpCl As New SmtpClient(SmtpSettings.MailServer, SmtpSettings.MailPort)
SmtpCl.Credentials = GetCredentials(SmtpSettings)
Dim MailMsg As New MailMessage(MsgFrom, MsgTo)
MailMsg.Subject = MsgSubject
MailMsg.Body = MsgText
Try
SmtpCl.Send(MailMsg)
Catch ex As Exception
Server.Transfer("UploadIncomplete.aspx", True)
End Try
End Sub
My question, is there a quick and dirty way for me to accomplish this?
Thanks,
Fed