如何让SmtpClient通过http代理服务器发送邮件

如何让SmtpClient通过http代理服务器发送邮件,第1张

HOST:smtp163com

public static string
CreateTimeoutTestMessage(string server)

{

string Success =
"发送成功";

try

{

string _to = "1035092449@qqcom";

string _from =
"young-20@163com";

string _subject = "Using the new SMTP client";

string _body =
@"Using this new feature, you can send an e-mail
message from an application very easily";

MailMessage message = new
MailMessage();

messageFrom = new
MailAddress(_from);

//可以利用MailMessageToAdd方法增加要发送的邮件地址

message To Add (new MailAddress ("652105072@qqcom"));

messageToAdd(new
MailAddress(_to));

messageSubject = _subject;

messageBody = _body;

//添加附件

Attachment a = new
Attachment(@"C:/Users/Administrator/Desktop/smtpclientrar");

messageAttachmentsAdd(a);

//设置邮箱的地址或IP

SmtpClient client = new
SmtpClient(server);

//设置邮箱端口,pop3端口:110, smtp端口是:25

clientPort = 25;

//设置超时时间

clientTimeout = 9999;

//要输入邮箱用户名与密码

clientCredentials = new NetworkCredential("young-20@163com", "");

clientSend(message);

}

catch (Exception ex)

{

Success = exToString();

}

return Success;

}

[c-sharp] view
plaincopyprint

public static string CreateTimeoutTestMessage(string server)

{

string Success = "发送成功";

try

{

string _to = "1035092449@qqcom";

string _from = "young-20@163com";

string _subject = "Using the new SMTP client";

string _body = @"Using this new feature, you can send an e-mail message from an application very easily";

MailMessage message = new MailMessage();

messageFrom = new MailAddress(_from);

//可以利用MailMessageToAdd方法增加要发送的邮件地址

message To Add (new MailAddress ("652105072@qqcom"));

messageToAdd(new MailAddress(_to));

messageSubject = _subject;

messageBody = _body;

//添加附件

Attachment a = new Attachment(@"C:/Users/Administrator/Desktop/smtpclientrar");

messageAttachmentsAdd(a);

//设置邮箱的地址或IP

SmtpClient client = new SmtpClient(server);

//设置邮箱端口,pop3端口:110, smtp端口是:25

clientPort = 25;

//设置超时时间

clientTimeout = 9999;

//要输入邮箱用户名与密码

clientCredentials = new NetworkCredential("young-20@163com", "");

clientSend(message);

}

catch (Exception ex)

{

Success = exToString();

}

return Success;

}

DABAN RP主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
网站模板库 » 如何让SmtpClient通过http代理服务器发送邮件

0条评论

发表评论

提供最优质的资源集合

立即查看 了解详情