大家好,又见面了,我是你们的朋友全栈君。

System.Net.WebProxy proxy
=
new
System.Net.WebProxy(
“
itgproxy.redmond.corp.microsoft.com:80
“
);
proxy.Credentials =
System.Net.CredentialCache.DefaultCredentials;
System.Net.GlobalProxySelection.Select =
proxy;
MailMessage m =
new
MailMessage();
m.From =
tbFrom.Text;
m.To =
tbTo.Text;
m.Subject =
tbSubject.Text;
m.Body =
tbBody.Text;
//
优先级

switch
(ddlp.SelectedIndex)

…
{
case 0:
m.Priority = MailPriority.High;
break;
case 1:
m.Priority = MailPriority.Low;
break;
default:
m.Priority = MailPriority.Normal;
break;
}
//
格式

if
(ddlp.SelectedIndex
==
0
)
m.BodyFormat =
MailFormat.Text;
else
m.BodyFormat =
MailFormat.Html;
//
以下设置服务器

if
(tbServer.Text
!=
“”
)

…
{
//以下代码适用于Framework1.1以上版本。
//SmtpMail.SmtpServer = tbServer.Text;
// m.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpauthenticate“,
// “1”); //basic authentication
// m.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendusername“,
// tbUserName.Text); //set your username here
// m.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendpassword“,
// tbPass.Text); //set your password here
}
//
以下处理附件

string
strFileName
=
FileSelect.PostedFile.FileName;
if
(strFileName
!=
“”
)
m.Attachments.Add(new
MailAttachment(strFileName));
SmtpMail.Send(m);
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/151995.html原文链接:https://javaforall.net
