Exceptions galore calling End after using Web.Mail

VBLady

Member
Joined
Nov 13, 2002
Messages
9
Location
Shelton, WA
What am I doing wrong?? Ive written the following code to use the Web.Mail to send an email:

Code:
        Dim objMail As Web.Mail.SmtpMail

        Dim objEmail As New System.Web.Mail.MailMessage()

        objMail.SmtpServer = lblSMTPValue.Text

        objEmail.To = txtTo.Text
        objEmail.From = txtFrom.Text
        objEmail.Subject = txtSubject.Text
        objEmail.Body = txtBody.Text

        objMail.Send(objEmail)

When the End gets called in my close button event, the following exception is raised:

An unhandled exception of type System.TypeLoadException occurred in system.windows.forms.dll

Additional information: [Resource lookup failed - infinite recursion detected. Resource name: TypeLoad_PartialBindFailed]

If I add in the following lines:

Code:
objEmail = Nothing
objMail = Nothing


I get this exception on End:

An unhandled exception of type System.ExecutionEngineException occurred in Unknown Module.


If I comment out the email code and do anything else in the program, then the errors do not occur on exit. Please help!

Thanks,
Frances
 
Back
Top