 |
BOOK: Beginning ASP.NET 4 : in C# and VB
 | This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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 19th, 2010, 01:54 PM
|
|
Authorized User
|
|
Join Date: Sep 2010
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Sending Email
I have configured my web.config like this
Code:
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network enableSsl="true" host="smtp.gmail.com" password="mypassword" userName="[email protected]" port="587"/>
</smtp>
</mailSettings>
</system.net>
</configuration>
and in the page load of the demo page i have put the following:
Code:
MailMessage mymessage = new MailMessage();
mymessage.Subject = "You have new msg";
mymessage.Body = "hello from planet wrox";
mymessage.From = new MailAddress("[email protected]", "hehe!");
mymessage.To.Add(new MailAddress("[email protected]", "Reciever Name!"));
SmtpClient smtp = new SmtpClient();
smtp.Send(mymessage);
the email gets sent from the email configured in the web.config, isn't it supposed to be sent from the email indentified in the mymessage.from code? and when i commented the mymessage.from line, i got an error, so why do we use it if it won't appear in the email?
|
|

September 19th, 2010, 02:13 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Nope. The e-mail address you are referring to is "just" your user name to authenticate with the SMTP server.
But you can specify the from address in the "from" attribute as shown in the book. Once you do that, you can leave out the From from your code.
Cheers,
Imar
|
|

September 19th, 2010, 02:16 PM
|
|
Authorized User
|
|
Join Date: Sep 2010
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
but when i specify the from address, the email shows the from is the email used in web.config????
|
|

September 19th, 2010, 02:55 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Isn't that exactly what you're after?
Imar
|
|

September 19th, 2010, 03:03 PM
|
|
Authorized User
|
|
Join Date: Sep 2010
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
the email in the web.config for authenticating me to send emails am I right? so i use google smtp in order to send emails, first question can I use like hotmail smtp and use a hotmail Email to authenticate? my other question is I don't want my email which I use to authenticate to appear in the From title, then what's the point of defining a from email called [email protected] which is not going to appear in the emails? I want to authenticate using an email and showing a from address using an alias.
in web.config >> my real email address
however to show from>> alias email address.
|
|

September 19th, 2010, 03:20 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Have you tried the from attribute on the smtp element in the web.config and specify the address you want to show in the From field in the mail? That's what it's for. You can override that default through code by setting the From property.
Some mail servers overrule the from address, BTW. So even though you set an explicit address in the from attribute in web.config, you still end up with the e-mail address associated with the account ou're uisng.
Cheers,
Imar
|
|

September 19th, 2010, 03:24 PM
|
|
Authorized User
|
|
Join Date: Sep 2010
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
yes i have tried it in the web.config also, but same result, it shows the authentication account as the from address.
|
|

September 19th, 2010, 03:38 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
In that case, I think your SMTP server is overruling the address, probably for security reasons.
Cheers,
Imar
|
|

September 19th, 2010, 04:45 PM
|
|
Authorized User
|
|
Join Date: Sep 2010
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
by smtp server you mean here smtp.gmail right? is there any other smtp I can use?
|
|

September 19th, 2010, 05:29 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
If you have an hotmail account you can use that one as well. Alternatively, your ISP / network provider may offer one....
Imar
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Sending email |
Sheraz Khan |
Classic ASP Basics |
1 |
December 12th, 2009 12:58 AM |
| Sending Email |
drjohnnygills |
BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 |
0 |
August 13th, 2009 05:09 AM |
| Need Help in sending email |
khalidj06 |
Forum and Wrox.com Feedback |
6 |
April 14th, 2006 08:16 AM |
| email sending |
msrnivas |
.NET Web Services |
6 |
June 26th, 2004 06:59 AM |
|
 |
|