471,570 Members | 986 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,570 software developers and data experts.

VB.NET 2005 System.Net.Mail Problem

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
2 4195
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
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.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.