This is a migrated thread and some comments may be shown as answers.

Email Send Problem

1 Answer 116 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mohamed
Top achievements
Rank 1
mohamed asked on 21 Oct 2011, 07:18 AM


Email Send Problem in those boded lines


String server = "587";
 
                                MailAddress from = new MailAddress("newgenetech@gmail.com");
                                MailAddress to = new MailAddress("mohideenrms@gmail.com");
                                System.Web.Mail.MailMessage message = new System.Web.Mail.MailMessage(from, to);
 
                                message.Subject = "Hello";
                                message.Body = "How are you";
 
                                SmtpClient client = new SmtpClient(server);
 
                                try
                                {                                   
                                    client.Send(message);
                                }
                                catch (Exception ex)
                                {
                                    throw new Exception(ex.Message, ex);
                                }

1 boded error message come like that

Doesn't contain a contractors take two arguments

2 boded error message come like that

(local variable)system.web.mail.mailing message error: the best overload method match for 'system.net.mail.Smptclient.Send'(system.web.mail.mailling message)has some invalid aruguments.

Thanks,
Mohamed.

1 Answer, 1 is accepted

Sort by
0
mohamed
Top achievements
Rank 1
answered on 21 Oct 2011, 12:00 PM
Problem Resolved,


System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                                 SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
                                 mail.From = new MailAddress("newgenetech@gmail.com");
                                 mail.To.Add(Email.Text);
                                 mail.Subject = "User Name and Password";
                                 mail.Body = "User Name  : " + username.Text + " Password : " + password.Text;
                                 SmtpServer.Port = 587;
                                 SmtpServer.Credentials = new System.Net.NetworkCredential("newgenetech@gmail.com","Enter The Password Here");
                                 SmtpServer.EnableSsl = true;
                                 SmtpServer.Send(mail);


Thanks,
Mohamed.
Tags
Grid
Asked by
mohamed
Top achievements
Rank 1
Answers by
mohamed
Top achievements
Rank 1
Share this question
or