Click here to Skip to main content
15,898,826 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
SmtpClient sc1 = new SmtpClient();
MailMessage msg = new MailMessage();
MailAddress mailform = new MailAddress(txtEmail.Text, txtName.Text);
String strmsg;
sc1.Host ="smtp.gmail.com";
sc1.Port = 25;
msg.From = mailform;
msg.To.Add("vineet163@gmail.com");
msg.Subject = "Query from User";
msg.IsBodyHtml = true;
strmsg = "<center><table><tr><td colspan=\"2\"> User Information:</td></tr> ";
strmsg += "<tr> <td> Name:</td> <td> " + txtName.Text + "</td></tr>";
strmsg += "<tr><td>Contact No.:</td><td>" + txtContactNumber.Text + "</td></tr>";
strmsg += "<tr><td>Email:</td><td>" + txtEmail.Text + "</td></tr>";
strmsg += "<tr><td>City:</td><td>" + ddlCity.SelectedItem.Text + "</td></tr>";
strmsg += "<tr><td>Inquery:</td><td>" + txtInquiry.Text + "</td></tr></table></center>";
msg.Body = strmsg;
sc1.Send(msg);
lblStatus.Text = "Your Query posted successfully.";


Using this code i want to send informaton on my gmail ID But this code is not working successfully plese Help me...


I want to do like This

when click on email option

this option is near on share tweeter, facebook, Bookmark on google etc.

I not want to give any password
Posted
Updated 4-Oct-10 23:10pm
v7

1 solution

VB
Dim basicAuthentication As System.Net.NetworkCredential = New System.Net.NetworkCredential("userid@gmail.com", "password")
sc1.EnableSsl = True
sc1.UseDefaultCredentials = False
sc1.Credentials = basicAuthentication

Add the above code in your application. Note the code is in VB. convert it into C#.
 
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