I'm trying to create a simple form that sends an email using my
company's exchange server. I'm using the System.Net.Mail Namespace of
the .net framework 2.0.
I've googled everywhere and i think my code is ok, however i keep
getting a "A connection attempt failed because the connected party did
not properly respond after a period of time, or established connection
failed because connected host has failed to respond" error every time.
Any one has any ideas why this is happening?
Imports System.Net.Mail
'Imports System.Web.Mail
Public Class frmsendmail
Inherits System.Windows. Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeCompo nent()
'Add any initialization after the InitializeCompo nent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.Componen tModel.IContain er
'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows. Forms.Label
Friend WithEvents Label2 As System.Windows. Forms.Label
Friend WithEvents Label3 As System.Windows. Forms.Label
Friend WithEvents Label4 As System.Windows. Forms.Label
Friend WithEvents txtServidor As System.Windows. Forms.TextBox
Friend WithEvents CmdEnviar As System.Windows. Forms.Button
Friend WithEvents txtDe As System.Windows. Forms.TextBox
Friend WithEvents txtPara As System.Windows. Forms.TextBox
Friend WithEvents txtAssunto As System.Windows. Forms.TextBox
Friend WithEvents txtEmail As System.Windows. Forms.TextBox
<System.Diagnos tics.DebuggerSt epThrough()Priv ate Sub
InitializeCompo nent()
Me.txtServidor = New System.Windows. Forms.TextBox
Me.CmdEnviar = New System.Windows. Forms.Button
Me.Label1 = New System.Windows. Forms.Label
Me.Label2 = New System.Windows. Forms.Label
Me.Label3 = New System.Windows. Forms.Label
Me.Label4 = New System.Windows. Forms.Label
Me.txtDe = New System.Windows. Forms.TextBox
Me.txtPara = New System.Windows. Forms.TextBox
Me.txtAssunto = New System.Windows. Forms.TextBox
Me.txtEmail = New System.Windows. Forms.TextBox
Me.SuspendLayou t()
'
'txtServidor
'
Me.txtServidor. Location = New System.Drawing. Point(136, 56)
Me.txtServidor. Name = "txtServido r"
Me.txtServidor. Size = New System.Drawing. Size(168, 20)
Me.txtServidor. TabIndex = 0
Me.txtServidor. Text = ""
Me.txtServidor. Visible = False
'
'CmdEnviar
'
Me.CmdEnviar.Lo cation = New System.Drawing. Point(344, 296)
Me.CmdEnviar.Na me = "CmdEnviar"
Me.CmdEnviar.Ta bIndex = 1
Me.CmdEnviar.Te xt = "Enviar"
'
'Label1
'
Me.Label1.Locat ion = New System.Drawing. Point(72, 56)
Me.Label1.Name = "Label1"
Me.Label1.Right ToLeft = System.Windows. Forms.RightToLe ft.No
Me.Label1.Size = New System.Drawing. Size(48, 23)
Me.Label1.TabIn dex = 2
Me.Label1.Text = "Servidor:"
Me.Label1.Visib le = False
'
'Label2
'
Me.Label2.Locat ion = New System.Drawing. Point(96, 96)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing. Size(32, 23)
Me.Label2.TabIn dex = 3
Me.Label2.Text = "De:"
'
'Label3
'
Me.Label3.Locat ion = New System.Drawing. Point(88, 136)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing. Size(40, 23)
Me.Label3.TabIn dex = 4
Me.Label3.Text = "Para:"
'
'Label4
'
Me.Label4.Locat ion = New System.Drawing. Point(80, 168)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing. Size(48, 23)
Me.Label4.TabIn dex = 5
Me.Label4.Text = "Assunto:"
'
'txtDe
'
Me.txtDe.Locati on = New System.Drawing. Point(136, 96)
Me.txtDe.Name = "txtDe"
Me.txtDe.Size = New System.Drawing. Size(168, 20)
Me.txtDe.TabInd ex = 6
Me.txtDe.Text = ""
'
'txtPara
'
Me.txtPara.Loca tion = New System.Drawing. Point(136, 136)
Me.txtPara.Name = "txtPara"
Me.txtPara.Size = New System.Drawing. Size(168, 20)
Me.txtPara.TabI ndex = 7
Me.txtPara.Text = ""
'
'txtAssunto
'
Me.txtAssunto.L ocation = New System.Drawing. Point(136, 176)
Me.txtAssunto.N ame = "txtAssunto "
Me.txtAssunto.S ize = New System.Drawing. Size(168, 20)
Me.txtAssunto.T abIndex = 8
Me.txtAssunto.T ext = ""
'
'txtEmail
'
Me.txtEmail.Loc ation = New System.Drawing. Point(40, 224)
Me.txtEmail.Mul tiline = True
Me.txtEmail.Nam e = "txtEmail"
Me.txtEmail.Siz e = New System.Drawing. Size(264, 88)
Me.txtEmail.Tab Index = 9
Me.txtEmail.Tex t = ""
'
'frmsendmail
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.ClientSize = New System.Drawing. Size(456, 390)
Me.Controls.Add (Me.txtEmail)
Me.Controls.Add (Me.txtAssunto)
Me.Controls.Add (Me.txtPara)
Me.Controls.Add (Me.txtDe)
Me.Controls.Add (Me.Label4)
Me.Controls.Add (Me.Label3)
Me.Controls.Add (Me.Label2)
Me.Controls.Add (Me.Label1)
Me.Controls.Add (Me.CmdEnviar)
Me.Controls.Add (Me.txtServidor )
Me.Name = "frmsendmai l"
Me.Text = "sendmail"
Me.ResumeLayout (False)
End Sub
#End Region
Private Sub CmdEnviar_Click (ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles CmdEnviar.Click
Dim oEmail As New MailMessage
Dim oSmtpServer As New Net.Mail.SmtpCl ient()
Try
With oEmail
.From = New MailAddress(txt De.Text)
.To.Add(txtPara .Text)
.IsBodyHtml = False
.Subject = Me.txtAssunto.T ext
.Body = Me.txtEmail.Tex t
.Priority = MailPriority.Hi gh
End With
oSmtpServer.Hos t = "my.exchange.se rver"
oSmtpServer.Del iveryMethod = SmtpDeliveryMet hod.Network
oSmtpServer.Por t = 25
oSmtpServer.Tim eout = 900000
oSmtpServer.Cre dentials =
Net.CredentialC ache.DefaultNet workCredentials
oSmtpServer.Sen d(oEmail)
MsgBox("Email was sent", MsgBoxStyle.Inf ormation, "Info:")
Catch ex As Exception
MsgBox(ex.Inner Exception.Inner Exception.Messa ge,
MsgBoxStyle.Exc lamation, ex.Message)
Finally
oEmail = Nothing
oSmtpServer = Nothing
End Try
End Sub
End Class 0 2776 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sven Templin |
last post by:
Hello all,
our configuration is as following described:
- OS: Windows 2000
- Apache server 1.3
- Php 3.8
- MS outlook client 2000
_and_ no SMTP server available in the whole intranet.
|
by: martin smith |
last post by:
Here's the scenario. I'm currently using cdosys/asp to send mail to
our SMTP server. We use a product called MailFilter to check for SPAM.
It doesn't work very well. If MailFilter isn't working cdosys also has
problems and emails don't get sent. As these email are confirmations
for customer's bookings this means lots of customers calling to see
where their confirmation emails have gone. The root of the problem is
MailFilter but that here...
|
by: Bonj |
last post by:
Right guys.
(I would like a solution to this in VB6 as this is what our needy app is
written in, but any solutions that involve .NET would be much appreciated
likewise as I could instantiate them, otherwise please forgive the
crossposting.)
I'm sure I've seen posts here before criticising the practice of automating
outlook for the purpose of programatically sending email, on the grounds that
it's naff. Well now we're really landed in...
|
by: Gaz |
last post by:
Hi all
I am currently trying to send and email via exchange except I'm having a
nightmare getting it working, you'd think this would be pertty simple
wouldn't you?
I have added a reference to cdoex.dll in my project and this is my code:
ADODB.ConnectionClass conn = null;
|
by: Jim in Arizona |
last post by:
I've made an application that is a computer problems (tickets) system. The
employee goes to a web page and posts the comptuer problem they're having.
Then, the IS staff goes to another webpage (both pages aspx of couse) which
shows the posts by the employees. From there, we assign the problems
(tickets) to each other, set priorities and add notes as neccessary.
What I want to do is, when an employee posts a new problem, have an email...
| |
by: Frank |
last post by:
I think I've confused myself completely here :-)
I have used System.Web.Mail, but am not sure if this works with Exchange Server 5.5. I asked the client if they're email server supported SMTP, and got the following reply (exact quote):
Exchange 5.5 uses IMS connector for communication between the internal and the external world. IMS is based on SMTP Protocol.
For mail flow within the organization Exchange 5.5 uses Message Transfer...
|
by: B-Dog |
last post by:
I've built a small app that sends mail through our ISP's SMTP server but
when I try to send through my local exchange server I get CDO error. Does
webmail use SMTP or does it strictly rely on CDOmail. I don't want to use
the Outlook reference because outlook prompts each time program access it
and I have found a way to disable that. Can I use webmail with exchange?
Thanks
|
by: Gilbert Cheung |
last post by:
Hello.
I am writing a website for my company. There is a sign-up form that requires
us to send a confirmation email to our customer. Our company uses Exchange
Server 2000 as our mail server. We decided not to implement any smtp server
as that may post some additional security risk. The question is, how can I
write an ASP.NET 1.1 script (in C#, though I think there is not much
difference between C# and VB.NET) that can send email,...
|
by: John |
last post by:
Hi
I have a vb.net win form app that runs on a MS Small Business Server 2003
(windows 20003 server + ISA 2000 + exchange 2000). My question is how can I
send external emails from the app via code? Is there any way to leave a copy
of the sent emails in a mailbox on exchange?
Thanks
Regards
|
by: sridhar |
last post by:
iam having user account on an exchangeserver.
with that can i send an email using python?
if iam using the following code iam getting error
fromAddress = 'sridhar_kasturi@satyam.com'
toAddress = 'sridhar_kasturi@satyam.com'
msg = "Subject: Hello\n\nThis is the body of the message."
import smtplib
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |