G
Guest
I am trying to send a simple mail message using windows forms in VB.NET 2005.
When executing the code, I get a general 'Configuration system failed to
initialize' error message when the code instatiates a new MailMessage object
(see below) My form has the following code:
Imports System.Net.Mail
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
SendMail("(e-mail address removed)")
End Sub
Private Sub SendMail(ByVal pTo As String)
Dim sSubject As String = "Test"
Dim sBody As String = "Test message."
' *** Error happens here ***
Dim oMail As New MailMessage
oMail.To.Add(New MailAddress(pTo))
oMail.Subject = sSubject
oMail.Body = sBody
Dim oSmtp As New SmtpClient
oSmtp.Send(oMail)
End Sub
End Class
My app.config file has the following:
<system.net>
<mailSettings>
<smtp from="(e-mail address removed)">
<network host="(localhost)" port="25" />
</smtp>
</mailSettings>
</system.net>
The Default SMTP Virtual Servier is running in IIS.
Could someone please provide some help with this?? Thanks.
Tim
When executing the code, I get a general 'Configuration system failed to
initialize' error message when the code instatiates a new MailMessage object
(see below) My form has the following code:
Imports System.Net.Mail
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
SendMail("(e-mail address removed)")
End Sub
Private Sub SendMail(ByVal pTo As String)
Dim sSubject As String = "Test"
Dim sBody As String = "Test message."
' *** Error happens here ***
Dim oMail As New MailMessage
oMail.To.Add(New MailAddress(pTo))
oMail.Subject = sSubject
oMail.Body = sBody
Dim oSmtp As New SmtpClient
oSmtp.Send(oMail)
End Sub
End Class
My app.config file has the following:
<system.net>
<mailSettings>
<smtp from="(e-mail address removed)">
<network host="(localhost)" port="25" />
</smtp>
</mailSettings>
</system.net>
The Default SMTP Virtual Servier is running in IIS.
Could someone please provide some help with this?? Thanks.
Tim