3
Contributors
8
Replies
9
Views
6 Years
Discussion Span
Last Post by erum
0

Sorry I can' access the link you mentioned in your post!
I suggest you to try the code below. I used that code in my project before and it worked fine with me.. this is asp.net using c# codes..

try
        {
            MailMessage mail = new MailMessage();
            mail.To.Add("email_add_of_the_receiver@gmail.com");
            mail.From = new MailAddress(email_of the_sender@yahoo.com);// or could be @gmail.com and etc OR it can be a textbox were you CAN enter your email
            mail.Subject = "Comment/Question";
            string Body = the_textbox_Name_were_you_enter_your_message.text;
                mail.Body = Body;
            mail.IsBodyHtml = true;
            SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp.gmail.com";
            smtp.Port = 587;
            smtp.Credentials = new System.Net.NetworkCredential
              ("email_add_of_the_receiver@gmail.com", "your password");
            smtp.EnableSsl = true;
            smtp.Send(mail);
           
        }
        catch
        {
            
        }

dont forget to include this one:

using System.Net.Mail;

Edited by kuracha: n/a

0

thanks kuracha for ur good reply ,really help me a lot

how about if need to send from msn or yahoo or hotmail ..just chnage following paramters

host ,creential,from ?? (Coorect me if i m worong)

0

i mgetting an error

{"Failure sending mail."}

i have set certian values in web.config

smtp.Credentials = New System.Net.NetworkCredential("no-reply@gfln.org", "Admin")
smtp.EnableSsl = True


mail.From = New MailAddress(System.Configuration.ConfigurationManager.AppSettings("From").ToString())



' or could be @gmail.com and etc OR it can be a textbox were you CAN enter your email
' mail.Subject = "Comment/Question"
mail.Subject = System.Configuration.ConfigurationManager.AppSettings("EmailSubject").ToString()

this time i m not sending mail via a gmail but website account ,

Edited by happygeek: fixed formatting

0

make sure that you leave the code as is , just provide your username and password it will work

System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
0

yes i also provide this line too

smtp.Credentials = New System.Net.NetworkCredential("reciever email", "password of sender")
smtp.EnableSsl = True

is this u r saying

0

no leave it empty as i provided in the article what you need to change its only the username and password of Gmail

0

yes i did the same as u saying but still no gain.secondly let me added some thing code.

i need to send mail from administrator of gln.org i.e no-reply@gfln.org.
its password is admin,and send email to its cleint .i hope u got my point, there is some exception {"The remote name could not be resolved: 'smtp.gfln.org'"}

please post back me

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.