用gmail发送的,根据你自己的邮箱调整一下就可以了 Sub sendmail(ByVal args() As String) If args.Length < 4 Then 'Console.WriteLine( _ ' "Expected: mailer.exe [from] [to] [subject] [message]") Response.Write("Expected: mailer.exe [from] [to] [subject] [message]") Exit Sub End If ' Set mailServerName to be the name of the mail server ' you wish to use to deliver this message Dim mailServerName As String = "smtp.gmail.com" Dim fromAddress As String = args(MailMessagePart.ToAddress) Dim toAddress As String = args(MailMessagePart.FromAddress) Dim subject As String = args(MailMessagePart.Subject) Dim body As String = args(MailMessagePart.Message) Try ' MailMessage is used to represent the e-mail being sent Using message As _ New MailMessage(fromAddress, toAddress, subject, body) ' SmtpClient is used to send the e-mail Dim mailClient As New SmtpClient(mailServerName) ' UseDefaultCredentials tells the mail client to use the ' Windows credentials of the account (i.e. user account) ' being used to run the application message.IsBodyHtml = True message.BodyEncoding = System.Text.Encoding.UTF8 mailClient.Port = 587 mailClient.EnableSsl = True mailClient.Credentials = New System.Net.NetworkCredential("gmail帐号", "gmail密码") 'mailClient.UseDefaultCredentials = True ' Send delivers the message to the mail server 'message.To.Add(New MailAddress("receive E-mail Address")) mailClient.Send(message) End Using Response.Write("Message sent.") Catch ex As FormatException Response.Write(ex.Message) Catch ex As SmtpException Response.Write(ex.Message) End Try End Sub
Sub sendmail(ByVal args() As String) If args.Length < 4 Then
'Console.WriteLine( _
' "Expected: mailer.exe [from] [to] [subject] [message]")
Response.Write("Expected: mailer.exe [from] [to] [subject] [message]")
Exit Sub
End If ' Set mailServerName to be the name of the mail server
' you wish to use to deliver this message
Dim mailServerName As String = "smtp.gmail.com"
Dim fromAddress As String = args(MailMessagePart.ToAddress)
Dim toAddress As String = args(MailMessagePart.FromAddress)
Dim subject As String = args(MailMessagePart.Subject)
Dim body As String = args(MailMessagePart.Message)
Try
' MailMessage is used to represent the e-mail being sent
Using message As _
New MailMessage(fromAddress, toAddress, subject, body) ' SmtpClient is used to send the e-mail
Dim mailClient As New SmtpClient(mailServerName)
' UseDefaultCredentials tells the mail client to use the
' Windows credentials of the account (i.e. user account)
' being used to run the application
message.IsBodyHtml = True
message.BodyEncoding = System.Text.Encoding.UTF8
mailClient.Port = 587
mailClient.EnableSsl = True mailClient.Credentials = New System.Net.NetworkCredential("gmail帐号", "gmail密码")
'mailClient.UseDefaultCredentials = True
' Send delivers the message to the mail server
'message.To.Add(New MailAddress("receive E-mail Address")) mailClient.Send(message)
End Using
Response.Write("Message sent.")
Catch ex As FormatException
Response.Write(ex.Message)
Catch ex As SmtpException
Response.Write(ex.Message)
End Try
End Sub
通过发送邮件public void MailSend(string MailFrom,string MailTo,string MailPwd,string Mailtitle,string MailCon)
{
MailMessage MyMail = new MailMessage();
MyMail.From = new MailAddress("", "");
MyMail.To.Add(new MailAddress(""));
MyMail.Subject = Mailtitle;
MyMail.Body = MailCon;
MyMail.IsBodyHtml = true;
SmtpClient smtpclient = new SmtpClient();
smtpclient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpclient.Host = "";
smtpclient.Credentials = new System.Net.NetworkCredential(MailFrom, MailPwd);
smtpclient.Send(MyMail);
}
string url = absoluteUri.Substring(0, absoluteUri.LastIndexOf('/')) + "/js.aspx";
Jnd.Utility.MailUtility Mail = new Jnd.Utility.MailUtility();
string subject = "你的主题";
string body = @"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='http://www.w3.org/1999/xhtml' >
<head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'><title>
系统用户激活
</title><link href='" + absoluteUri.Substring(0, absoluteUri.LastIndexOf('/')) + @"/style/global.css' rel='stylesheet' type='text/css' />
<style type='text/css'>
.style1
{
width: 100%;
}
.style2
{
width: 864px;
}
.style3
{
width: 130px;
}
</style>
</head>
<body>
<form name='form1' method='post' action='" + url + @"' id='form1'>
<input type='hidden' name='__VIEWSTATE' id='__VIEWSTATE' value='/wEPDwUKMjEyNDM4ODI5MA9kFgICAw9kFgYCAQ8WAh4EVGV4dAUPd2NobTE4OUAxNjMuY29tZAIDDxYCHwAFB3djaG0xODlkAgUPFgIfAAUn5YyX5Lqs5p2w6IO96L6+56eR5oqA6K6+5aSH5pyJ6ZmQ5YWs5Y+4ZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WAQUMSW1hZ2VCdXR0b24x2STa+bTlHtQx4LuL+Bo2NlBCHxg=' /><input type='hidden' name='__EVENTVALIDATION' id='__EVENTVALIDATION' value='/wEWAgKgkPReAtLCmdMIV9jiOrGAZXvLaAb/iKqjyTvl0DA=' />
<div class='container'>
<div class='br'>
<table cellpadding='0' cellspacing='0' class='style1'>
<tr>
<td>
<div align='left'>
<table cellpadding='0' cellspacing='0' style='width: 650px;'>
<tr>
<td style='width: 25px;'>
</td>
<td colspan='3' style='width: 620px;'>
<img src='" + absoluteUri.Substring(0, absoluteUri.LastIndexOf('/')) + @"//images/register/bg.gif' alt='' />
</td>
<td>
</td>
</tr>
<tr>
<td height='25px'>
</td>
<td height='25px' class='style3'>
邮 箱: </td>
<td class='style2'>
" + user.Email + @"
</td>
<td style='width: 340px;'>
</td>
</tr>
<tr>
<td height='25px'>
</td>
<td height='30px' class='style3'>
</td>
<td colspan='2'>
( 帮助您找回密码和网站信息发布 )
</td>
</tr>
<tr>
<td height='25px'>
</td>
<td height='25px' class='style3'>
登录用户名:
</td>
<td class='style2'>
" + user.UserName + @"
</td>
<td>
</td>
</tr>
<tr>
<td height='25px'>
</td>
<td height='25px' class='style3'>
</td>
<td colspan='2'>
( 您登录网站后台的帐号 )
</td>
</tr>
<tr>
<td height='25px'>
</td>
<td height='25px' class='style3'>
公 司 名 称:
</td>
<td class='style2'>
" + user.CompanyName + @"
</td>
<td>
</td>
</tr>
<tr>
<td height='25px'>
</td>
<td height='25px' class='style3'>
</td>
<td colspan='2'>
( 您的企业名称 )
</td>
</tr>
<tr>
<td height='40px'>
</td>
<td height='49px' class='style3'>
</td>
<td class='style2'>
<input type='image' name='ImageButton1' id='ImageButton1' src='" + absoluteUri.Substring(0, absoluteUri.LastIndexOf('/')) + @"/images/register/activation.png' border='0' />
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td colspan='3'>
</td>
<td>
</td>
</tr>
</table>
</div>
</td>
<td style='width: 5px;'>
</td>
<td style='width: 300px; line-height: 25px; vertical-align: top; padding-top: 40px;'>
说明:
<br />
1、登录用户名只在登录时使用,别人看不到。<br />
2、显示名称即昵称。
<br />
3、注册的帐户通过邮件激活后才能使用,请正确填写您的邮箱。
<br />
4、注册过程中如果遇到任何问题,请随时联系管理员。
</td>
</tr>
</table>
</div>
</div>
</form>
</body>
</html>
";
Mail.SendMail(txtEmail.Text, subject, body);
protected bool sendemail()
{
jmail.Message jmail = new jmail.Message();
jmail.Silent = true;
jmail.Logging = true;
jmail.Charset = "UTF-8";
jmail.Encoding = "Base64";
jmail.AddRecipient("[email protected]","","");
jmail.AddRecipientCC("[email protected]","","");
jmail.From = "[email protected]";
jmail.MailServerUserName = "方";
jmail.MailServerPassWord = ".......";
jmail.Subject = "测试主题";
jmail.HTMLBody = "内容";
bool flag = jmail.Send("smtp.163.com.cn", false);
return flag;
}这样写有错么,jmail.Send()里面的参数是什么意思啊 怎么写的??电脑上要不要装什么发邮件的东西??谁给我详细说一下 啊