 |
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
 | This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|
|

September 20th, 2009, 08:06 AM
|
|
Registered User
|
|
Join Date: Sep 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Imar,
Thanks for the quick response. I got it to work now. It looks like it was a combination of setting my login credentials, turning my firewall off and not liking the EnableSsl.
Thanks for your help!
|
|

September 21st, 2009, 04:49 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
|
|
error in sending emails
Hello Imar
This is my first post to the site and as other persons had faced problem the same I have. I can not send emails with the examples given in your book. Well I have found this book as "best of breed" but emailing is really bottleneck. I have used TRY & CATCH blocks as well as suggested in one of the posts. But I still have problem, it always executes the CATCH block.
Also please specify more that in code where to write " [email protected]" as it is, and where to replace it with the real data.
I use gmail account and my email Id is "[email protected]".
And also specify that should it need to be replaced
into relevant information or leave it as it is.
Please reply me as soon as possible as I have been dealing with this problem for last 6 days. 
|
|

September 21st, 2009, 05:13 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
|
|
Error in Sending Email
Hello Imar
This is my first post to the site and as other persons had faced problem the same I have. I can not send emails with the examples given in your book. Well I have found this book as "best of breed" but emailing is really bottleneck. I have used TRY & CATCH blocks as well as suggested in one of the posts. But I still have problem, it always executes the CATCH block.
Also please specify more that in code where to write " [email protected]" as it is, and where to replace it with the real data.
I use gmail account and my email Id is "[email protected]".
And also specify that should it need to be replaced
into relevant information or leave it as it is.
Please reply me as soon as possible as I have been dealing with this problem for last 6 days. 
|
|

September 21st, 2009, 05:13 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Jack,
As indicated in the book, you *always* need to replace [email protected] with your own e-mail address; it's just a placeholder meant to refer to your own e-mail address.
If you're using a Gmail account, does that also mean you're using GMail's mail server? If so, did you try the code I posted earlier in this thread? You need to set the port number and set EnableSsl to true.
The problem with sending mail is that there are way too many different configurations so the book couldn't deal with them all. However, if you're using GMail's SMTP server the book's example should work.
If this doesn't help, can you post your exact code and the config section from web.config? Don't forget to replace your password and other sensitive data before you post here.
Cheers,
Imar
|
|

September 21st, 2009, 05:16 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Heuh? Did you just post the same question again? If so, why? Or is that a forum bug?
Imar
|
|

September 21st, 2009, 05:16 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
|
|
just a minute
Ok Sir, just wait a minute I am looking for my site.
|
|

September 21st, 2009, 05:21 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
|
|
sending codes
contact form.ascx.cs
Code:
Namespaces here
public partial class controls_WebUserControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
if (txtPhoneHome.Text != string.Empty || txtPhoneBusiness.Text != string.Empty)
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}
protected void btnSend_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
string fileName = Server.MapPath("~/App_Data/ContactForm.txt");
//string mailBody = string.Empty;
//if (Cache["ContactFormMailBody"] == null)
//{
// mailBody = System.IO.File.ReadAllText(fileName);
// Cache.Insert("ContactFormMailBody", mailBody, new CacheDependency(fileName));
//}
//else
//{
// mailBody = Cache["ContactFormMailBody"].ToString() + "\r\n( )";//stops dirty message from being sent
//}
string mailBody = System.IO.File.ReadAllText(fileName);
mailBody = mailBody.Replace("##name##", txtName.Text);
mailBody = mailBody.Replace("##Email##", txtEmailAddress.Text);
mailBody = mailBody.Replace("##HomePhone##", txtPhoneHome.Text);
mailBody = mailBody.Replace("##BusinessPhone##", txtPhoneBusiness.Text);
mailBody = mailBody.Replace("##Comments##", txtComments.Text);
MailMessage myMessage = new MailMessage();
myMessage.Subject = "Response From Web Site";
myMessage.Body = mailBody;
myMessage.From = new MailAddress("[email protected]", "Sender Name Here");
myMessage.To.Add(new MailAddress("[email protected]", "jack"));
SmtpClient mySmtpClient = new SmtpClient();
try
{
mySmtpClient.EnableSsl = true;
mySmtpClient.Send(myMessage);
}
catch (Exception ex)
{
//ex.Message;
lblMessage.Text = "An error occurred while sending your e-mail. Please try again.";
}
//mySmtpClient.Send(myMessage);
lblMessage.Visible = true;
FormTable.Visible = false;
//System.Threading.Thread.Sleep(5000);
}
}
}
web config file
<system.net>
<mailSettings>
<smtp from="jack <[email protected]>" deliveryMethod="Network">
<network host="smtp.gmail.com" userName="vkhilaryjack" password="PASSWORD" port="587"/>
</smtp>
</mailSettings>
</system.net>
|
|

September 21st, 2009, 05:29 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
|
|
code sent
hello sir, I have sent the code I used, please guide me regarding this.......
|
|

September 21st, 2009, 05:29 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Four things to try:
1. Make sure that in web.config you use vkhilaryjack @ gmail dot com (as one word / valid e-mail address, don't want to post your full address here) and not just vkhilaryjack. Gmail wants a full e-mail address.
2. Try the code I posted earlier that explicitly sets the Credentials property of the client.
3. Make sure you replace [email protected] as discussed earlier. I am pretty sure GMail requires you to supply a valid e-mail address.
4. Remove the Try/Catch block so you can see what the actual error is....
|
|

September 21st, 2009, 05:30 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Quote:
|
hello sir, I have sent the code I used, please guide me regarding this.......
|
Yes, I can see it. Please allow for more than 5 seconds before expecting a reply...... ;-)
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Chapter 16 Viewforum issue |
EgoGen |
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 |
0 |
June 12th, 2008 04:18 AM |
| chapter 12 loginin issue |
marcusth |
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 |
2 |
December 27th, 2007 01:11 PM |
| session_start issue (Chapter 12) |
preston2003 |
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 |
7 |
April 15th, 2005 03:09 AM |
|
 |