View Full Version : Sending Emails Through Web App
meadowstrav
04-10-2003, 07:16 AM
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
bruce
04-10-2003, 11:28 AM
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
[b]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">
bruce
04-11-2003, 02:02 AM
Check your from address and make sure it's valid.
Many mail server do not accept mail from invalid mail from address.
[b]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 = "myname@domain.com";
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
myname@domain.com.
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">
MSolve1
04-11-2003, 10:45 AM
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 = "myname@domain.com";
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
myname@domain.com.
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
bruce
04-18-2003, 12:07 AM
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: <mail.From@domain.com>
To: <mail.To@domain.com>
MSolve1
04-18-2003, 12:21 AM
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
[b]From: <mail.From@domain.com>
To: <mail.To@domain.com>
</blockquote id="quote"></font id="quote">
bruce
04-18-2003, 01:22 AM
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).
[b]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
[b]From: <mail.From@domain.com>
To: <mail.To@domain.com>
</blockquote id="quote"></font id="quote">
</blockquote id="quote"></font id="quote">
MSolve1
04-18-2003, 07:38 AM
Bruce,
I tried to replace the FROM field to a string constant
(i.e. mail.From = "myname@domain.com") but still no results..
No exceptions being catched.
Any other ideas?
Menard
[b]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.
[b]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 = "myname@domain.com";
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
myname@domain.com.
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">
bruce
04-18-2003, 10:45 AM
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.
[b]quote:Originally posted by MSolve1
Bruce,
I tried to replace the FROM field to a string constant
(i.e. mail.From = "myname@domain.com") but still no results..
No exceptions being catched.
Any other ideas?
Menard
[b]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.
[b]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 = "myname@domain.com";
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
myname@domain.com.
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">
MSolve1
04-18-2003, 11:38 AM
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.
<mail.To@domain.com>:
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: <mail.From@domain.com>
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: <mail.From@domain.com>
To: <mail.To@domain.com>
Subject: Product Inquiry
Date: Fri, 11 Apr 2003 11:15:14 -0700
Message-ID: <01d901c30056$4c958280$4764a8c0@dotnetplayground.co m>
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: mail.From@domain.com
X-OriginalArrivalTime: 11 Apr 2003 18:15:14.0871 (UTC) FILETIME=[4C97CC70:01C30056]
...
Need HELP!
Thanks
MSolve1
----------
[b]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.
[b]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 = "myname@domain.com";
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
myname@domain.com.
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">
MSolve1
04-21-2003, 09:10 AM
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?
[b]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).
[b]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
[b]From: <mail.From@domain.com>
To: <mail.To@domain.com>
</blockquote id="quote"></font id="quote">
</blockquote id="quote"></font id="quote">
</blockquote id="quote"></font id="quote">
vBulletin® ©Jelsoft Enterprises Ltd.