Sending Emails Through Web App

Discussion in 'ASP.NET / ASP.NET Core' started by meadowstrav, Apr 10, 2003.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hello,

    I am trying to create a "forgot password" section to my login section of my website. However, I do not know how to create and send emails with asp.net. Can someone please lead me in the right direction?

    Thanks,

    David
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    Dave,

    You can use the system.web.mail class. You should set the Web.Mail.SmtpMail.SmtpServer property to localhost

    There are many example on the Internet, i found a couple on google.

    http://www.aspmatrix.com/asp-net/send_mail_message_example/index.aspx

    http://www.dotnetgenius.com/default.aspx?Article=21


    quote:Originally posted by meadowstrav

    Hello,

    I am trying to create a "forgot password" section to my login section of my website. However, I do not know how to create and send emails with asp.net. Can someone please lead me in the right direction?

    Thanks,

    David
    </blockquote id="quote"></font id="quote">
     
  3. Bruce

    Bruce DiscountASP.NET Staff

    Check your from address and make sure it's valid.

    Many mail server do not accept mail from invalid mail from address.

    quote:Originally posted by MSolve1

    How come the following code is not working?


    private void SubmitButton_Click(object sender, System.EventArgs e)
    {
    Server.ScriptTimeout = 1000;
    Response.Flush();

    SmtpMail.SmtpServer = "localhost";

    MailMessage mail = new MailMessage();
    mail.To = "[email protected]";
    mail.From = this.EmailField.Text;
    mail.Subject = this.SubjectList.SelectedItem.Text;
    mail.Body = this.MessageField.Text;

    try
    {
    SmtpMail.Send(mail);
    }

    catch(System.Exception ex)
    {
    ResponseLabel.Text = ex.Message;
    }
    Response.Flush();
    }


    For some reason, the mail is not being sent to
    [email protected].

    I tried changing 'SmtpMail.SmtpServer = "localhost"', to the following:

    1. SmtpMail.SmtpServer = "mail.finsoftware.com";
    2. //SmtpMail.SmtpServer = "mail.finsoftware.com"; (commented out)

    and yet it's still not being sent and there are no exceptions being catched.

    Anyone help would be highly appreciated.

    Thanks

    MSolve1


    </blockquote id="quote"></font id="quote">
     
  4. How come the following code is not working?


    private void SubmitButton_Click(object sender, System.EventArgs e)
    {
    Server.ScriptTimeout = 1000;
    Response.Flush();

    SmtpMail.SmtpServer = "localhost";

    MailMessage mail = new MailMessage();
    mail.To = "[email protected]";
    mail.From = this.EmailField.Text;
    mail.Subject = this.SubjectList.SelectedItem.Text;
    mail.Body = this.MessageField.Text;

    try
    {
    SmtpMail.Send(mail);
    }

    catch(System.Exception ex)
    {
    ResponseLabel.Text = ex.Message;
    }
    Response.Flush();
    }


    For some reason, the mail is not being sent to
    [email protected].

    I tried changing 'SmtpMail.SmtpServer = "localhost"', to the following:

    1. SmtpMail.SmtpServer = "mail.finsoftware.com";
    2. //SmtpMail.SmtpServer = "mail.finsoftware.com"; (commented out)

    and yet it's still not being sent and there are no exceptions being catched.

    Anyone help would be highly appreciated.

    Thanks

    MSolve1
     
  5. Bruce

    Bruce DiscountASP.NET Staff

    From the rejected mail, it's obvious that you are trying to send to a invalid address. It'll work find once you put in the write address

    From: <[email protected]>
    To: <[email protected]>
     
  6. Nope, I replaced that part manually before I posted it here, coz I don't wanna list down my real e-mail addy to avoid spam. I'm sure it's a valid e-mail address (that's why I was able to receive the failure notice).

    quote:Originally posted by bruce

    From the rejected mail, it's obvious that you are trying to send to a invalid address. It'll work find once you put in the write address

    From: <[email protected]>
    To: <[email protected]>


    </blockquote id="quote"></font id="quote">
     
  7. Bruce

    Bruce DiscountASP.NET Staff

    hmmm....

    can you try send it to an hotmail or yahoo account?



    quote:Originally posted by MSolve1

    Nope, I replaced that part manually before I posted it here, coz I don't wanna list down my real e-mail addy to avoid spam. I'm sure it's a valid e-mail address (that's why I was able to receive the failure notice).

    quote:Originally posted by bruce

    From the rejected mail, it's obvious that you are trying to send to a invalid address. It'll work find once you put in the write address

    From: <[email protected]>
    To: <[email protected]>


    </blockquote id="quote"></font id="quote">
    </blockquote id="quote"></font id="quote">
     
  8. Bruce,

    I tried to replace the FROM field to a string constant
    (i.e. mail.From = "[email protected]") but still no results..
    No exceptions being catched.

    Any other ideas?

    Menard

    quote:Originally posted by bruce

    Check your from address and make sure it's valid.

    Many mail server do not accept mail from invalid mail from address.

    quote:Originally posted by MSolve1

    How come the following code is not working?


    private void SubmitButton_Click(object sender, System.EventArgs e)
    {
    Server.ScriptTimeout = 1000;
    Response.Flush();

    SmtpMail.SmtpServer = "localhost";

    MailMessage mail = new MailMessage();
    mail.To = "[email protected]";
    mail.From = this.EmailField.Text;
    mail.Subject = this.SubjectList.SelectedItem.Text;
    mail.Body = this.MessageField.Text;

    try
    {
    SmtpMail.Send(mail);
    }

    catch(System.Exception ex)
    {
    ResponseLabel.Text = ex.Message;
    }
    Response.Flush();
    }


    For some reason, the mail is not being sent to
    [email protected].

    I tried changing 'SmtpMail.SmtpServer = "localhost"', to the following:

    1. SmtpMail.SmtpServer = "mail.finsoftware.com";
    2. //SmtpMail.SmtpServer = "mail.finsoftware.com"; (commented out)

    and yet it's still not being sent and there are no exceptions being catched.

    Anyone help would be highly appreciated.

    Thanks

    MSolve1


    </blockquote id="quote"></font id="quote">
    </blockquote id="quote"></font id="quote">
     
  9. Bruce

    Bruce DiscountASP.NET Staff

    Hmmmm.....

    I am not sure what's happening. If the SMTPMail.send is not giving you any error. That means the mail is somewhere in the mail server. The only reason the mail is not delivering in this case is that the from & to address are invalid. I do not think it is related to your code.

    What I would do is to try change the send to address to some hotmail or yahoo address and see if it work.

    quote:Originally posted by MSolve1

    Bruce,

    I tried to replace the FROM field to a string constant
    (i.e. mail.From = "[email protected]") but still no results..
    No exceptions being catched.

    Any other ideas?

    Menard

    quote:Originally posted by bruce

    Check your from address and make sure it's valid.

    Many mail server do not accept mail from invalid mail from address.

    quote:Originally posted by MSolve1

    How come the following code is not working?


    private void SubmitButton_Click(object sender, System.EventArgs e)
    {
    Server.ScriptTimeout = 1000;
    Response.Flush();

    SmtpMail.SmtpServer = "localhost";

    MailMessage mail = new MailMessage();
    mail.To = "[email protected]";
    mail.From = this.EmailField.Text;
    mail.Subject = this.SubjectList.SelectedItem.Text;
    mail.Body = this.MessageField.Text;

    try
    {
    SmtpMail.Send(mail);
    }

    catch(System.Exception ex)
    {
    ResponseLabel.Text = ex.Message;
    }
    Response.Flush();
    }


    For some reason, the mail is not being sent to
    [email protected].

    I tried changing 'SmtpMail.SmtpServer = "localhost"', to the following:

    1. SmtpMail.SmtpServer = "mail.finsoftware.com";
    2. //SmtpMail.SmtpServer = "mail.finsoftware.com"; (commented out)

    and yet it's still not being sent and there are no exceptions being catched.

    Anyone help would be highly appreciated.

    Thanks

    MSolve1


    </blockquote id="quote"></font id="quote">
    </blockquote id="quote"></font id="quote">
    </blockquote id="quote"></font id="quote">
     
  10. Here's what's being sent to my email addy (entered in the FROM field) addy:

    Hi. This is the qmail-send program at mail01.dotnetplayground.com.
    I'm afraid I wasn't able to deliver your message to the following addresses.
    This is a permanent error; I've given up. Sorry it didn't work out.

    <[email protected]>:
    Sorry, I wasn't able to establish an SMTP connection. (#4.4.1)
    I'm not going to try again; this message has been in the queue too long.

    --- Below this line is a copy of the message.

    Return-Path: <[email protected]>
    Received: (qmail 7295 invoked from network); 11 Apr 2003 18:15:15 -0000
    Received: from unknown (HELO web101.dotnetplayground.com) (192.168.100.71)
    by mail01.dotnetplayground.com with SMTP; 11 Apr 2003 18:15:15 -0000
    Received: from web101 ([127.0.0.1]) by web101.dotnetplayground.com with Microsoft SMTPSVC(5.0.2195.5329);
    Fri, 11 Apr 2003 11:15:14 -0700
    From: <[email protected]>
    To: <[email protected]>
    Subject: Product Inquiry
    Date: Fri, 11 Apr 2003 11:15:14 -0700
    Message-ID: <[email protected]>
    MIME-Version: 1.0
    Content-Type: text/plain;
    charset="iso-8859-1"
    Content-Transfer-Encoding: quoted-printable
    X-Mailer: Microsoft CDO for Windows 2000
    Thread-Index: AcMAVkyVNzIREc3rQleWGAALU8QzYg==
    Content-Class: urn:content-classes:message
    X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
    Return-Path: [email protected]
    X-OriginalArrivalTime: 11 Apr 2003 18:15:14.0871 (UTC) FILETIME=[4C97CC70:01C30056]

    ...


    Need HELP!

    Thanks

    MSolve1
    ----------


    quote:Originally posted by bruce

    Check your from address and make sure it's valid.

    Many mail server do not accept mail from invalid mail from address.

    quote:Originally posted by MSolve1

    How come the following code is not working?


    private void SubmitButton_Click(object sender, System.EventArgs e)
    {
    Server.ScriptTimeout = 1000;
    Response.Flush();

    SmtpMail.SmtpServer = "localhost";

    MailMessage mail = new MailMessage();
    mail.To = "[email protected]";
    mail.From = this.EmailField.Text;
    mail.Subject = this.SubjectList.SelectedItem.Text;
    mail.Body = this.MessageField.Text;

    try
    {
    SmtpMail.Send(mail);
    }

    catch(System.Exception ex)
    {
    ResponseLabel.Text = ex.Message;
    }
    Response.Flush();
    }


    For some reason, the mail is not being sent to
    [email protected].

    I tried changing 'SmtpMail.SmtpServer = "localhost"', to the following:

    1. SmtpMail.SmtpServer = "mail.finsoftware.com";
    2. //SmtpMail.SmtpServer = "mail.finsoftware.com"; (commented out)

    and yet it's still not being sent and there are no exceptions being catched.

    Anyone help would be highly appreciated.

    Thanks

    MSolve1


    </blockquote id="quote"></font id="quote">
    </blockquote id="quote"></font id="quote">
     
  11. Bruce, it finally worked when I used my AOL and YAHOO e-mail in
    either FROM and TO fields. For some reason, it's not working
    for my company e-mail! I'm quite sure it's a valid e-mail addy
    because, obviously it's the one I use for work. I remember it worked at least once, for some reason it stopped working.


    quote:Originally posted by bruce

    hmmm....

    can you try send it to an hotmail or yahoo account?



    quote:Originally posted by MSolve1

    Nope, I replaced that part manually before I posted it here, coz I don't wanna list down my real e-mail addy to avoid spam. I'm sure it's a valid e-mail address (that's why I was able to receive the failure notice).

    quote:Originally posted by bruce

    From the rejected mail, it's obvious that you are trying to send to a invalid address. It'll work find once you put in the write address

    From: <[email protected]>
    To: <[email protected]>


    </blockquote id="quote"></font id="quote">
    </blockquote id="quote"></font id="quote">
    </blockquote id="quote"></font id="quote">
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page