sending an email...

Discussion in 'ASP .Net' started by RAB, Dec 19, 2006.

  1. RAB

    RAB Guest

    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 = ""
    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 = ""

    '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
     
    RAB, Dec 19, 2006
    #1
    1. Advertising

  2. 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.




    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en espaƱol : http://asp.net.do/foros/
    ===================================
    "RAB" <> wrote in message
    news:...
    >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 = ""
    > 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 = ""
    >
    > '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
    >
     
    Juan T. Llibre, Dec 19, 2006
    #2
    1. Advertising

  3. RAB

    Mark Rae Guest

    "RAB" <> wrote in message
    news:...

    > 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...
     
    Mark Rae, Dec 19, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick
    Replies:
    2
    Views:
    5,992
    Gopinath S
    Feb 15, 2005
  2. =?Utf-8?B?dWZyYWY=?=

    sending email thro SMTP server

    =?Utf-8?B?dWZyYWY=?=, May 20, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    2,775
    =?Utf-8?B?dWZyYWY=?=
    May 30, 2005
  3. Replies:
    0
    Views:
    1,485
  4. Luke
    Replies:
    2
    Views:
    4,817
    Nigel Wade
    Mar 15, 2007
  5. rote
    Replies:
    8
    Views:
    796
Loading...

Share This Page