smtp.Send fail


B

bgreer5050

I have a form with the following fields:

UserEmail
Subject
Body

When the form is submitted, the email is processed fine. When I try
to add another field to the mm.body (mm.Body = Body.Text &
Listbox1.SelectedItem.Text) the smtp.Send fails. Any ideas ?


Code:

<script runat="server">
Protected Sub SendEmail_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles SendEmail.Click
'!!! UPDATE THIS VALUE TO YOUR EMAIL ADDRESS
Const ToAddress As String = "(e-mail address removed)"

'(1) Create the MailMessage instance
Dim mm As New Net.Mail.MailMessage(UsersEmail.Text, ToAddress)

'(2) Assign the MailMessage's properties
mm.Subject = Subject.Text
mm.Body = Body.Text & TextBox1.Text
mm.IsBodyHtml = False

'(3) Create the SmtpClient object
Dim smtp As New Net.Mail.SmtpClient

'(4) Send the MailMessage (will use the Web.config settings)
smtp.Send(mm)
End Sub


</script>
 
Ad

Advertisements

T

ThatsIT.net.au

Does the server have smtp

if not you need to tell smtpclient where to find one

Dim message As New MailMessage("[email protected]", "[email protected]", "Subject",
"Message Text")

Dim emailClient As New SmtpClient("Email Server Name")

emailClient.Send(message)
 
T

ThatsIT.net.au

sorry did not read your post correctly

try writing

response.write(Body.Text & Listbox1.SelectedItem.Text)

see what you get
 
J

Just Me

Also.....

Put a try/catch block around the code and see what that kicks up if anything
 
B

bgreer5050

sorry did not read your post correctly

try writing

response.write(Body.Text & Listbox1.SelectedItem.Text)

see what you get













- Show quoted text -

I tried the response.write and I get a valid text string. When I try
to use Body.Text & Listbox1.SelectedItem.text togethor I get the
following failure:

Exception Details: System.Net.Mail.SmtpException: Service not
available, closing transmission channel. The server response was:
Command timeout, closing transmission channel

It's almost as if the server is timing out.
 
B

bgreer5050

Also.....

Put a try/catch block around the code and see what that kicks up if anything









- Show quoted text -

I put the Try Catch block around the script and it worked. Why would
adding a try catch eliminate the problem?
 
Ad

Advertisements

B

bgreer5050

I tried the response.write and I get a valid text string. When I try
to use Body.Text & Listbox1.SelectedItem.text togethor I get the
following failure:

Exception Details: System.Net.Mail.SmtpException: Service not
available, closing transmission channel. The server response was:
Command timeout, closing transmission channel

It's almost as if the server is timing out.- Hide quoted text -

- Show quoted text -

Well....I guess I do not understand the Try/Catch. The page did not
error out, but the email was never sent as well.
 
J

Just Me

The point of the try catch is this

Try

Your Stuff

Catch ex as exception

'// Look at your exception message here, it will give you more
information

End Try
 
G

Guest

Hi,

First of all, check if it's a code problem, or if it is a network /
permissions issue, try to send and e-mail using telnet:

http://msexchangeteam.com/archive/2006/07/14/428324.aspx

If you cannot send an e-mail using this, just grab the network admin and
have a chat with him.

I have compiled good info about SMTP and .net (FAQS and Articles):

http://www.tipsdotnet.com/ArticleBlog.aspx?KWID=45&Area=SMTP&PageIndex=0

Good luck
Braulio

/// ------------------------------
/// Braulio Diez
///
/// http://www.tipsdotnet.com
/// ------------------------------
 
T

ThatsIT.net.au

I tried the response.write and I get a valid text string. When I try
to use Body.Text & Listbox1.SelectedItem.text togethor I get the
following failure:

Exception Details: System.Net.Mail.SmtpException: Service not
available, closing transmission channel. The server response was:
Command timeout, closing transmission channel

It's almost as if the server is timing out.


This error seems not to be related to your text string, but to do with smtp
not being available.
make sure you have smtp working and tell smtp client what computer it is on

Dim emailClient As New SmtpClient("Email Server Name")
 
B

bgreer5050

Thank you very much. The SMTP server I use is on a remote system. Is
there a way to use the "telnet localhost smtp" command with my remote
smtp proivider?

The smtp server is smtp.infosaic.com.

Thanks

P.S. Nice Blog
 
Ad

Advertisements

B

bgreer5050

Is there suppose to be a command in the code to tell the smtp service,
that you are finished using it?
 
B

bgreer5050

I checked out your samples. I am having a problem with:

authenicationMode="SSL"

I put this in my web.config mail settings and when I put the mouse
over it, i get the following message:

"The authenticationMode attribute is not declared"

Can you please help?
 
Ad

Advertisements

Ad

Advertisements

J

Just Me

Jesus, Guys, this is really 'NOT' that difficult. Does the OP want a fresh
perspective on this ?
 

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