I can use outlook2003 to send email,but I cann't use this code below to send
email.
Please help me to test this code and instruct me how to solve this problem
in detail.
software environment: VS2005 + XP.-- I have disabled firewall
hardware enviornmnet:t elcom's modem connects hub,hub connects two
computers.。-- I also tried to connect computer to modem directly,but I can
surf internet, not send email with code.
=============== ==============
System.Net.Mail .SmtpClient client = new SmtpClient();
client.Host = "smtp.gmail.com ";
client.Port = 465;
client.UseDefau ltCredentials = false;
client.Credenti als = new System.Net.Netw orkCredential(" uid", "pwd");
//I also try to use full email address to replace uid. It didn't work.
client.Delivery Method = SmtpDeliveryMet hod.Network;
System.Net.Mail .MailMessage message = new
MailMessage("ui d@hotmail.com", "uid@hotmail.co m", "Subject",
"Body");
message.BodyEnc oding = System.Text.Enc oding.UTF8;
message.IsBodyH tml = true;
try
{
client.Send(mes sage);
Response.Write( "Email successfully sent.");
}
catch (Exception ex)
{
Response.Write( "Send Email Failed." + ex.ToString()); ;
}
===============
email.
Please help me to test this code and instruct me how to solve this problem
in detail.
software environment: VS2005 + XP.-- I have disabled firewall
hardware enviornmnet:t elcom's modem connects hub,hub connects two
computers.。-- I also tried to connect computer to modem directly,but I can
surf internet, not send email with code.
=============== ==============
System.Net.Mail .SmtpClient client = new SmtpClient();
client.Host = "smtp.gmail.com ";
client.Port = 465;
client.UseDefau ltCredentials = false;
client.Credenti als = new System.Net.Netw orkCredential(" uid", "pwd");
//I also try to use full email address to replace uid. It didn't work.
client.Delivery Method = SmtpDeliveryMet hod.Network;
System.Net.Mail .MailMessage message = new
MailMessage("ui d@hotmail.com", "uid@hotmail.co m", "Subject",
"Body");
message.BodyEnc oding = System.Text.Enc oding.UTF8;
message.IsBodyH tml = true;
try
{
client.Send(mes sage);
Response.Write( "Email successfully sent.");
}
catch (Exception ex)
{
Response.Write( "Send Email Failed." + ex.ToString()); ;
}
===============
Comment