如何用vs2005发送电子邮件? [英] How to send email with vs2005?

查看:73
本文介绍了如何用vs2005发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用outlook2003发送电子邮件???但我不能使用下面的代码发送

电子邮件。

请帮我测试一下这段代码并指导我如何解决这个问题

详细说明。


软件环境??? VS2005 + XP .--我已禁用防火墙

硬件enviornmnet ??? telcom'的调制解调器连接集线器???集线器连接两台
台计算机。 - 我也尝试将计算机直接连接到调制解调器,但我可以上网冲浪,而不是用代码发送电子邮件。


======= ======================

System.Net.Mail.SmtpClient client = new SmtpClient();

client.Host =" smtp.gmail.com";

client.Port = 465;

client.UseDefaultCredentials = false;

client.Credentials = new System.Net.NetworkCredential(" uid"," pwd");

//我也尝试使用完整的电子邮件地址来替换uid。它没用。

client.DeliveryMethod = SmtpDeliveryMethod.Network;


System.Net.Mail.MailMessage message = new

MailMessage(" ui * @ hotmail.com"," ui * @ hotmail.com"," Subject",


" Body");

message.BodyEncoding = System.Text.Encoding.UTF8;

message.IsBodyHtml = true;


试试

{

client.Send(message);

Response.Write(" Email successfully sent。);

}

catch(exception ex)

{

Response.Write(" Send Email Failed。" + ex.ToString()); ;

}

===============

解决方案

您的登录名是uid吗?和你的密码pwd?如果没有,请将这些值

更改为您的登录ID和密码。这应该可以让事情顺利进行。


-

Gregory A. Beamer

MVP; MCP:+ I,SE,SD,DBA


***************************

在盒子外面思考!

*************************** >
" Chef"写道:


我可以使用outlook2003发送电子邮件???但我不能使用下面的代码发送

电子邮件。

请帮我测试一下这段代码并指导我如何解决这个问题

详细说明。


软件环境?? ? VS2005 + XP .--我已禁用防火墙

硬件enviornmnet ??? telcom'的调制解调器连接集线器???集线器连接两台
台计算机。 - 我也尝试将计算机直接连接到调制解调器,但我可以上网冲浪,而不是用代码发送电子邮件。


======= ======================

System.Net.Mail.SmtpClient client = new SmtpClient();

client.Host =" smtp.gmail.com";

client.Port = 465;

client.UseDefaultCredentials = false;

client.Credentials = new System.Net.NetworkCredential(" uid"," pwd");

//我也尝试使用完整的电子邮件地址来替换uid。它没用。

client.DeliveryMethod = SmtpDeliveryMethod.Network;


System.Net.Mail.MailMessage message = new

MailMessage(" ui * @ hotmail.com"," ui * @ hotmail.com"," Subject",


" Body");

message.BodyEncoding = System.Text.Encoding.UTF8;

message.IsBodyHtml = true;


试试

{

client.Send(message);

Response.Write(" Email successfully sent。);

}

catch(exception ex)

{

Response.Write(" Send Email Failed。" + ex.ToString()); ;

}

===============


< BLOCKQUOTE>"厨师" < Ch ** @ discuss.microsoft.com写信息

新闻:7A ************************** ******** @ microsof t.com ...


但我不能使用下面的代码发送电子邮件。



尝试时会发生什么...?


我使用我的真实用户名和密码来替换" UID"和pwd在代码中。


" Cowboy(Gregory A. Beamer) - MVP"写道:


您的登录名是uid吗?和你的密码pwd?如果没有,请将这些值

更改为您的登录ID和密码。这应该可以让事情顺利进行。


-

Gregory A. Beamer

MVP; MCP:+ I,SE,SD,DBA


***************************

在盒子外面思考!

*************************** >

" Chef"写道:


我可以使用outlook2003发送电子邮件???但我不能使用下面的代码发送

电子邮件。

请帮我测试一下这段代码并指导我如何解决这个问题

详细说明。


软件环境?? ? VS2005 + XP .--我已禁用防火墙

硬件enviornmnet ??? telcom'的调制解调器连接集线器???集线器连接两台
台计算机。 - 我也尝试将计算机直接连接到调制解调器,但我可以上网冲浪,而不是用代码发送电子邮件。


======= ======================

System.Net.Mail.SmtpClient client = new SmtpClient();

client.Host =" smtp.gmail.com";

client.Port = 465;

client.UseDefaultCredentials = false;

client.Credentials = new System.Net.NetworkCredential(" uid"," pwd");

//我也尝试使用完整的电子邮件地址来替换uid。它没用。

client.DeliveryMethod = SmtpDeliveryMethod.Network;


System.Net.Mail.MailMessage message = new

MailMessage(" ui * @ hotmail.com"," ui * @ hotmail.com"," Subject",


" Body");

message.BodyEncoding = System.Text.Encoding.UTF8;

message.IsBodyHtml = true;


试试

{

client.Send(message);

Response.Write(" Email successfully sent。);

}

catch(exception ex)

{

Response.Write(" Send Email Failed。" + ex.ToString()); ;

}

===============


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???telcom''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.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("uid", "pwd");
//I also try to use full email address to replace uid. It didn''t work.
client.DeliveryMethod = SmtpDeliveryMethod.Network;

System.Net.Mail.MailMessage message = new
MailMessage("ui*@hotmail.com", "ui*@hotmail.com", "Subject",

"Body");
message.BodyEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = true;

try
{
client.Send(message);
Response.Write("Email successfully sent.");
}
catch (Exception ex)
{
Response.Write("Send Email Failed." + ex.ToString()); ;
}
===============

解决方案

Is your logon name "uid" and your password "pwd"? If not, change these values
to your logon id and password. That should get things running.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Chef" wrote:

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???telcom''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.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("uid", "pwd");
//I also try to use full email address to replace uid. It didn''t work.
client.DeliveryMethod = SmtpDeliveryMethod.Network;

System.Net.Mail.MailMessage message = new
MailMessage("ui*@hotmail.com", "ui*@hotmail.com", "Subject",

"Body");
message.BodyEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = true;

try
{
client.Send(message);
Response.Write("Email successfully sent.");
}
catch (Exception ex)
{
Response.Write("Send Email Failed." + ex.ToString()); ;
}
===============


"Chef" <Ch**@discussions.microsoft.comwrote in message
news:7A**********************************@microsof t.com...

but I cann''t use this code below to send email.

What happens when you try...?


I used my real user name and password to replace "uid" and "pwd" in the code.

"Cowboy (Gregory A. Beamer) - MVP" wrote:

Is your logon name "uid" and your password "pwd"? If not, change these values
to your logon id and password. That should get things running.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Chef" wrote:

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???telcom''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.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("uid", "pwd");
//I also try to use full email address to replace uid. It didn''t work.
client.DeliveryMethod = SmtpDeliveryMethod.Network;

System.Net.Mail.MailMessage message = new
MailMessage("ui*@hotmail.com", "ui*@hotmail.com", "Subject",

"Body");
message.BodyEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = true;

try
{
client.Send(message);
Response.Write("Email successfully sent.");
}
catch (Exception ex)
{
Response.Write("Send Email Failed." + ex.ToString()); ;
}
===============


这篇关于如何用vs2005发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆