472,958 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 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 4262
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: sathyashrayan | last post by:
Following are the selected thread from the date:30-jan-2005 to 31-jan-2005. I did not use any name because of the subject is important. You can get the original thread by typing the subject...
2
by: Tony Mastracchio | last post by:
Trying to send email via vb 2005 win form. I'm able to send email out via Outlook express from this account and I verified everything 100 times, I don't think it's my host email server. I can't...
14
by: Professor Yonce | last post by:
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. It Will not build. Public Class...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.