View Full Version : aspNetEmail sends 2 copies of same email
gibletz
05-10-2004, 09:12 AM
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.
gibletz
05-11-2004, 08:20 AM
Here ya go:
-------------------------------------------------------
EmailMessage emailObj = new EmailMessage("mail.somemailserver.com");
emailObj.To = "office@somemailserver.com";
emailObj.Cc = "webmaster@somemailserver.com";
emailObj.FromAddress = TextBox_EmailAddress.Text;
emailObj.Subject = "FEEDBACK";
emailObj.BodyFormat = MailFormat.Html;
emailObj.Body =
"Email Address: [b]" + TextBox_EmailAddress.Text + "</b>
" +
"Hear About Us: [b]" + DropDownList_HearAbout.SelectedItem.Value + "</b>
" +
"Comments: [b]" + 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!
bruce
05-11-2004, 11:11 AM
pls post code
[b]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">
Scott
05-12-2004, 04:50 AM
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.
[b]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">
gibletz
05-12-2004, 10:02 AM
D'oh! Thanks Scott. I knew a second set of eyes would find something :p
vBulletin® ©Jelsoft Enterprises Ltd.