exception

G

Guest

hi,

i have an exception in my code for a contact form:

protected void SendMessage_Click(object sender, EventArgs e)
{
MailMessage msg = new MailMessage();
msg.From = new MailAddress(FromAddress.Text);
string[] cc = ToAddress.Text.Split(';');
foreach (string s in cc)
{
msg.CC.Add(new MailAddress(s));
}
msg.Subject = "** BRUNEL WEBSITE CONTACT FORM SUBMISSION **";
msg.Body = EMailMessage.Text;
msg.IsBodyHtml = false;
SmtpClient client = new SmtpClient();
client.Host = "smtp.gmail.com";
client.UseDefaultCredentials = true;
-->> client.Send(msg);
StatusLabel.Text = "Mail sent successfully!";
}
the debugger tells me that i need a secure connection. i dont know what that
is or how to get one.
would i need to know stuff like this as a begginer?
thanks if you can help me!
 
A

Alvin Bruney - ASP.NET MVP

change this line client.Host = "smtp.gmail.com";
to client.Host = "localhost"; see if that helps


--
Warm Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley 2006
Blog: http://msmvps.com/blogs/Alvin/
 
J

Justin Burnham

Try adding this line with host set to smtp.gmail.com

client.EnableSsl = true , I believe that Gmail would want to use Ssl for its
connections and normally SmtpClient has EnableSsl set to false as default.\

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top