By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,660 Members | 1,103 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,660 IT Pros & Developers. It's quick & easy.

VB.NET 2005 System.Net.Mail Problem

P: n/a
Tim
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("us**@domain.com")
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="te**@domain.com">
<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

Sep 7 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi. I am having exact same problem, but with a console app.
Did you ever get this resolved?

Tim wrote:
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("us**@domain.com")
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="te**@domain.com">
<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
Sep 27 '06 #2

P: n/a
Tim, I am having an EMail problem also from my VB 2005 Express form.

I saw your message. I do not understand this in your message. I have never
seen it listed this way before and I have written several windows appl
programs.

What is strange to me is: this below lines about your App.config file.
My app.config file has the following:

<system.net>
<mailSettings>
<smtp from="te**@domain.com">
<network host="(localhost)" port="25" />
</smtp>
</mailSettings>
</system.net>
I have made form for E-Mail. I have entered code but the Import system does
not work. It has squiggly line underneath it showing it is not communicating.
Will not build.

Public Class Form3Bio1
System.Net.Mail.SmtpClient
Imports System.Net.Mail
' I XXX out certain entrys below just for this publication.

Dim emailSender As SmtpClient
Dim theMessage As MailMessage
Dim SHost As String = ("smtp.XXXXX.com")
Dim Passwd As String = ("Harold45")
Dim Recv As String = ("In****@XXXXXX.Com")
Dim Sndr As String = ("Ha****@XX.Com")
Dim Body As String = (Form4Bio1.TextBox5.Text) +
(Form4Bio1.ListBox1.Items)
emailSender = New System.Net.Mail.SmtpClient( _
SHost)

theMessage = New MailMessage
theMessage.From = New MailAddress(Sndr)
theMessage.To.Add(Recv)
theMessage.Subject = (Form4Bio1.TextBox4.Text)
theMessage.password = (Passwd)
theMessage.Body = (Form4Bio1.TextBox5.Text) +
(Form4Bio1.ListBox1.Items)

I have tried Importing the System.Net.Mail but can't find it. I have .Net
2.0 installed.
My form system just does not allow System nor recognize the System.Net
Thanks for your kind help in advance.
Tim, is my problem because I have not set up a Config file like you listed
above?
I do not know where a Config file is made. Thanks.
--
Professor Yonce, Retired commercial pilot. Also retired college department
Director and Professor. Presently a Communications Consultant and Developer.
Was this post helpful to you?
--
Professor Yonce, Retired commercial pilot. Also retired college department
Director and Professor. Presently a Communications Consultant and Developer.
"ir*******@gmail.com" wrote:
Hi. I am having exact same problem, but with a console app.
Did you ever get this resolved?

Tim wrote:
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("us**@domain.com")
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="te**@domain.com">
<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

Dec 3 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.