email not received

S

susie

I have the following code to send out a test email to myself. I did not get any error message and has been informed that the email has been sent. However I never received the mail. Even if I am not online and run the following code, I still message that email has been sent. Any idea how to fix the problem? I checked my smpt server by typing "net start smtpsvc" at the command prompt, smtp server is starting all the time when I was running the code.
<%@ Page Language="VB" EnableSessionState="False" EnableViewState="False" Trace="False" Debug="true"%><%@ Import Namespace="System.Web.Mail" %><script language="VB" runat=server>

Sub Page_Load(Sender as Object, E as EventArgs)
If Page.IsPostBack Then
lblResponse.Text = "Your email has been sent."
End If
End Sub

Sub btn_Click(sender as Object, e as System.EventArgs)
Dim objEmail as New MailMessage(
objEmail.To = txtTo.Tex
objEmail.From = "(e-mail address removed)
'objEmail.Cc = txtCc.Tex
objEmail.Subject = "Test Email
'objEmail.Body = txtName.Text & ", " &txtComments.Tex
'objEmail.Priority = MailPriority.Hig
SmtpMail.SmtpServer = "localhost
tr
SmtpMail.Send(objEMail
Response.Write("Your E-mail has been sent sucessfully You"

catch exc as Exceptio
Response.Write("Send failure: " + exc.ToString()
End Tr

End Sub

</script><html><head><style>
..main {font-family:Verdana; font-size:12px;}
..title {font-family:Verdana; font-size:18px; font-weight:bold;}
</style></head><body><span class="title" align="center">Send email from
an ASP.NET page</span><br><br><asp:Label class="main" id="lblResponse"
runat="server"/><form method="POST" name="MainForm" runat="server"><table><tr><td class="main" align="right">Email:</td><td class="main"><asp:textbox id="txtTo" runat="server"/></td></tr><tr><td class="main" align="right">
Subject:</td><td class="main"><input type="text"
class="main" name="Subject" value=""></td></tr><tr><td class="main" align="right"
valign="top">Message:</td><td class="main"><textarea name="Message"
cols="50" rows="8"></textarea></td></tr><tr><td class="main">&nbsp;</td><td class="main"><input type="Submit"
id="btnSubmit" OnServerClick="btn_Click" value="Send"
runat="server" /></td></tr></table></form></body></html


Thank you very much for your input
 
C

CMA

comment the three lines in the page load method. then set the label text
from the two messeges get from the btn_click method. and see what is the
output. this is because u may not getting the actual error. because it is
ovewritten by the page_load message. since always call the page_load
automatically every time the page refresh, u'll get "Your email has been
sent." though there is an error.

code should like this (not compiled)

Sub Page_Load(Sender as Object, E as EventArgs)
' If Page.IsPostBack Then
' lblResponse.Text = "Your email has been sent."
' End If
End Sub

Sub btn_Click(sender as Object, e as System.EventArgs)
Dim objEmail as New MailMessage()
objEmail.To = txtTo.Text
objEmail.From = "(e-mail address removed)"
'objEmail.Cc = txtCc.Text
objEmail.Subject = "Test Email"
'objEmail.Body = txtName.Text & ", " &txtComments.Text
'objEmail.Priority = MailPriority.High
SmtpMail.SmtpServer = "localhost"
try
SmtpMail.Send(objEMail)
lblResponse.Text = "Your E-mail has been sent sucessfully You"

catch exc as Exception
lblResponse.Text = "Send failure: " + exc.ToString()
End Try

End Sub


what is the message u got????
****************************************************************************
********************



susie said:
I have the following code to send out a test email to myself. I did not
get any error message and has been informed that the email has been sent.
However I never received the mail. Even if I am not online and run the
following code, I still message that email has been sent. Any idea how to
fix the problem? I checked my smpt server by typing "net start smtpsvc" at
the command prompt, smtp server is starting all the time when I was running
the code.
<%@ Page Language="VB" EnableSessionState="False" EnableViewState="False"
Trace="False" Debug="true"%> said:
Sub Page_Load(Sender as Object, E as EventArgs)
If Page.IsPostBack Then
lblResponse.Text = "Your email has been sent."
End If
End Sub

Sub btn_Click(sender as Object, e as System.EventArgs)
Dim objEmail as New MailMessage()
objEmail.To = txtTo.Text
objEmail.From = "(e-mail address removed)"
'objEmail.Cc = txtCc.Text
objEmail.Subject = "Test Email"
'objEmail.Body = txtName.Text & ", " &txtComments.Text
'objEmail.Priority = MailPriority.High
SmtpMail.SmtpServer = "localhost"
try
SmtpMail.Send(objEMail)
Response.Write("Your E-mail has been sent sucessfully You")

catch exc as Exception
Response.Write("Send failure: " + exc.ToString())
End Try

End Sub

</script><html><head><style>
.main {font-family:Verdana; font-size:12px;}
.title {font-family:Verdana; font-size:18px; font-weight:bold;}
</style></head><body><span class="title" align="center">Send email from
an ASP.NET page</span><br><br><asp:Label class="main" id="lblResponse"
runat="server"/><form method="POST" name="MainForm"
runat="server"><table><tr><td class="main" align="right">Email:</td><td
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top