sending an email...

R

RAB

I have a .aspx page with the following code:

<% @Import Namespace="System.Web.Mail" %>
<%@ page language="vb" debug="true" runat="server" %>

<script runat="server">

Sub Click(sender as Object, e as EventArgs)

'Create an instance of the MailMessage class
Dim objMM as New MailMessage()

'Set the properties - send the email to the person who filled out the
'feedback form.
objMM.To = "(e-mail address removed)"
objMM.From = txtEmail.Text

'If you want to CC this email to someone else, uncomment the line
below
'objMM.Cc = ""

'If you want to BCC this email to someone else, uncomment the line
below
'objMM.Bcc = "(e-mail address removed)"

'Send the email in text format
objMM.BodyFormat = MailFormat.Text
'(to send HTML format, change MailFormat.Text to MailFormat.Html)

'Set the priority - options are High, Low, and Normal
objMM.Priority = MailPriority.Normal

'Set the subject
objMM.Subject = "Hello"

'Set the body
objMM.Body = txtMessage.Text

'Specify to use the default Smtp Server
SmtpMail.SmtpServer = ""

'Now, to send the message, use the Send method of the SmtpMail class
SmtpMail.Send(objMM)


panelSendEmail.Visible = false
panelMailSent.Visible = true
End Sub

</script>


<html>
<head>
<title>AnyPage</title>
</head>
<body>
<form runat="server">

<b>Your Email Address:</b>

<asp:textbox id="txtEmail" runat="server" />
<asp:requiredfieldvalidator controltovalidate="txtEmail"
runat="server"
Errormessage="Please enter an email address.">
</asp:requiredfieldvalidator><br>

<asp:RegularExpressionValidator
id="valUrl"
ControlToValidate="txtEmail"
Text="(invalid email address)"

ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
Runat="Server" />
</asp:RegularExpressionValidator>


<p>

<b>Your Message:</b><br>

<asp:textbox id="txtMessage" TextMode="MultiLine"
Columns="40" Rows="10"
runat="server" />
<asp:requiredfieldvalidator controltovalidate="txtMessage"
runat="server"
Errormessage="Please enter a message.">
</asp:requiredfieldvalidator>
<p>

<asp:button runat="server" id="btnSendFeedback" Text="Send
Email"
OnClick="Click" />



<asp:panel id="panelMailSent" runat="server" Visible="False">
An email has been sent. Thanks!
<br><br>

</asp:panel>
<br><br><br><br>

</form>
</body>
</html>

My question is, if my code sends this email and the email is
undeliverable. How can I notify myself of this information?

Thanks,
RABMissouri2006
 
J

Juan T. Llibre

re:
My question is, if my code sends this email and the email is
undeliverable. How can I notify myself of this information?

You can't...and you don't need to.

The email server which receives the attempt to send the email
will send back a notification to whomever is in the objMM.From address.





RAB said:
I have a .aspx page with the following code:

<% @Import Namespace="System.Web.Mail" %>
<%@ page language="vb" debug="true" runat="server" %>

<script runat="server">

Sub Click(sender as Object, e as EventArgs)

'Create an instance of the MailMessage class
Dim objMM as New MailMessage()

'Set the properties - send the email to the person who filled out the
'feedback form.
objMM.To = "(e-mail address removed)"
objMM.From = txtEmail.Text

'If you want to CC this email to someone else, uncomment the line
below
'objMM.Cc = ""

'If you want to BCC this email to someone else, uncomment the line
below
'objMM.Bcc = "(e-mail address removed)"

'Send the email in text format
objMM.BodyFormat = MailFormat.Text
'(to send HTML format, change MailFormat.Text to MailFormat.Html)

'Set the priority - options are High, Low, and Normal
objMM.Priority = MailPriority.Normal

'Set the subject
objMM.Subject = "Hello"

'Set the body
objMM.Body = txtMessage.Text

'Specify to use the default Smtp Server
SmtpMail.SmtpServer = ""

'Now, to send the message, use the Send method of the SmtpMail class
SmtpMail.Send(objMM)


panelSendEmail.Visible = false
panelMailSent.Visible = true
End Sub

</script>


<html>
<head>
<title>AnyPage</title>
</head>
<body>
<form runat="server">

<b>Your Email Address:</b>

<asp:textbox id="txtEmail" runat="server" />
<asp:requiredfieldvalidator controltovalidate="txtEmail"
runat="server"
Errormessage="Please enter an email address.">
</asp:requiredfieldvalidator><br>

<asp:RegularExpressionValidator
id="valUrl"
ControlToValidate="txtEmail"
Text="(invalid email address)"

ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
Runat="Server" />
</asp:RegularExpressionValidator>


<p>

<b>Your Message:</b><br>

<asp:textbox id="txtMessage" TextMode="MultiLine"
Columns="40" Rows="10"
runat="server" />
<asp:requiredfieldvalidator controltovalidate="txtMessage"
runat="server"
Errormessage="Please enter a message.">
</asp:requiredfieldvalidator>
<p>

<asp:button runat="server" id="btnSendFeedback" Text="Send
Email"
OnClick="Click" />



<asp:panel id="panelMailSent" runat="server" Visible="False">
An email has been sent. Thanks!
<br><br>

</asp:panel>
<br><br><br><br>

</form>
</body>
</html>

My question is, if my code sends this email and the email is
undeliverable. How can I notify myself of this information?

Thanks,
RABMissouri2006
 
M

Mark Rae

My question is, if my code sends this email and the email is
undeliverable. How can I notify myself of this information?

The mail server will automatically notify the sender...
 

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,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top