Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
Hi I am using the concept of sending email through asp.net on click of button. After registering, a customer who want to send mail to other friends for referencing our site when clicking a 'Tell to friend' button, but the customers who are not ready to give their password.
Can they send mail without password.
Please help

Thank you,
Soumya

[Op Adds]

Hai,
Thanks for your response


C#
public void sendmailto_Deal(string from,string to, string body)
{
MailMessage m = new MailMessage();
SmtpClient sc = new SmtpClient();

try
{
m.From = new MailAddress(from, "displayname");
m.To.Add(new MailAddress(to, "displayname"));


m.Subject = " This is a Test Mail";
m.IsBodyHtml = true;
m.Body = body;
sc.Host = "smtp.gmail.com";
sc.Port = 587;
sc.Credentials = new
System.Net.NetworkCredential("xxx", "xxx");
sc.EnableSsl = true;
sc.Send(m);
}
catch (Exception ex)
{

}
}

hai here we are using this code
here can i use as blank space("") instead of password?
does it work?
System.Net.NetworkCredential("xxx", "xxx");
Posted
Updated 21-Jan-11 2:16am
v3
Comments
Sandeep Mewara 21-Jan-11 0:28am    
No idea why it was downvoted! Countered.
#realJSOP 21-Jan-11 8:21am    
Do NOT add an answer to respond to other answers. Use the "Add Comment" link underneath the answer you want to respond to.

Why don't you create a single no-reply user account on whatever email server you're using, and when the users click "tell a friend", you can form the email (using the user's name in the subject line), and send the email from the common user account, and they don't have to enter ANYTHING, including their user Id or the email account password. All they have to do is click the button, and the web page does the rest for them.
 
Share this answer
 
but the customers who are not ready to give their password.
It's not the personal passwords that are required. It's the password of exchange server that you need to configure in your application known to Admins only.

All you need is to configure the email settings properly and allow users to use it. Personal username-passwords not needed. You can even send mails from a 'From' emailid that does not exists.

If needed, have a look at this Microsoft Video tutorial:
Use ASP.NET to send Email from Website[^]
 
Share this answer
 
Comments
Hiren solanki 21-Jan-11 8:17am    
Comment from OP: can u pls give the codedomo
it will be very helpfull to me

Pls help
Thank you,
Soumya
John's way is correct, this is the way all sites work really.

e.g

C#
public void sendmailto_Deal(string from, string to, string body)
{
    MailMessage m = new MailMessage();
    SmtpClient sc = new SmtpClient();
    try
    {
        m.From = new MailAddress("no-reply@yourserver.com");
        m.To.Add(new MailAddress(to, "displayname"));

        m.Subject = string.Format("YourApplicationName - New email from {0}!", from);
        m.IsBodyHtml = true;
        m.Body = body;
        sc.Host = "smtp.gmail.com";
        sc.Port = 587;
        sc.Credentials = new System.Net.NetworkCredential("xxx", "xxx"); // Whatever *your* email server settings are, NOT the users settings
        sc.EnableSsl = true;
        sc.Send(m);
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900