VB 2003, 0x80040213

T

Tull Clancey

Hi all.

I'm using the following code to attempt to send Email, it's part of an
application I'm writing. I don't need any fancy stuff, just a simple text
message. This code is just for testing but the final thing wont be any
different apart from dragging info from a database.

I can't get around the dreaded 0x80040213 error, The transport failed to
connect to the server.

From and To are definately correct, I've tried my ISP hostname, IP and
localhost and nothing changes, same error.

What pre-requisites do I need before I can send mail? Exchange? a local
SMTP server?

I've always understood as long as I have a Gateway connection to a router,
'localhost' should find my ISP and forward mail, as long as they receive on
port 25. I've checked all virus protection, port 25 is open, can't see
anything in the firewall that should cause a problem.

I've searched every group I can think of, most point to Exchange errors.
The annoying think is, I'm sure this worked 6 months ago!

Any help would be very much appreciated!


Dim mail As System.Web.Mail.SmtpMail
Dim msg As New System.Web.Mail.MailMessage

msg.From = txtFrom.Text
msg.To = txtRecip.Text
msg.Subject = txtSubject.Text
msg.Body = txtMessage.Text
msg.BodyFormat = MailFormat.Text

mail.SmtpServer = "localhost"

Try
mail.Send(msg)
Catch ex As Exception
MsgBox(ex.ToString)

While Not (ex.InnerException Is Nothing)
ex = ex.InnerException
MsgBox(ex.ToString)
End While

End Try
 
G

Guest

You will need an SMTP server you can relay through. <localhost> refers to
the machine you are running the application from; most PCs don't have an SMTP
server or smartrelay on them, and <localhost> will not find your ISP, since
by definition <localhost> is the PC the application is running on.

You will need to know the Fully Qualified Domain Name (i.e.
servername.isp.com) of the SMTP server, and be allowed to relay through it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top