aspNetEmail sends 2 copies of same email

Discussion in 'ASP.NET / ASP.NET Core' started by gibletz, May 10, 2004.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I have several forms on a website (asp.net) that get emailed to either one email address or 2 seperate email addresses. The issue is that no matter what form is used, 2 copies of the same email/form are sent. There is nothing in the code that would cause this anomaly. I was using the SMTP mail component without this issue just recently.

    Any insight into this would be great!

    Thanks.
     
  2. Here ya go:
    -------------------------------------------------------
    EmailMessage emailObj = new EmailMessage("mail.somemailserver.com");

    emailObj.To = "[email protected]";
    emailObj.Cc = "[email protected]";
    emailObj.FromAddress = TextBox_EmailAddress.Text;

    emailObj.Subject = "FEEDBACK";

    emailObj.BodyFormat = MailFormat.Html;

    emailObj.Body =
    "Email Address: " + TextBox_EmailAddress.Text + "</b>

    " +
    "Hear About Us: " + DropDownList_HearAbout.SelectedItem.Value + "</b>

    " +
    "Comments: " + Textarea_Comments.Value + "</b>";

    emailObj.Send();

    if ( emailObj.Send() )
    {
    Response.Redirect("/thankyou.aspx?t=feedback");
    }
    else
    {
    Response.Write("The following error occured: " + emailObj.LastException().Message);
    }
    -------------------------------------------------------

    Thanks!
     
  3. Bruce

    Bruce DiscountASP.NET Staff

    pls post code

    quote:Originally posted by gibletz

    I have several forms on a website (asp.net) that get emailed to either one email address or 2 seperate email addresses. The issue is that no matter what form is used, 2 copies of the same email/form are sent. There is nothing in the code that would cause this anomaly. I was using the SMTP mail component without this issue just recently.

    Any insight into this would be great!

    Thanks.
    </blockquote id="quote"></font id="quote">
     
  4. The first two lines in the following code, both of which contain "emailObj.Send() are causing the double send. Remove the first line and keep the one in the if block and it should work.

    quote:emailObj.Send(); ***** this line sends your email *****

    if ( emailObj.Send() ) ***** this line also sends it *****
    {
    Response.Redirect("/thankyou.aspx?t=feedback");
    }
    else
    {</blockquote id="quote"></font id="quote">
     
  5. D'oh! Thanks Scott. I knew a second set of eyes would find something :p
     
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