怎么发不出去呢
????
请高手指点
是不是还少点啥
Imports System.Web.Mail
Imports System.IO
Imports System.Web
Imports System
Imports System.Web.Util
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web 窗体设计器生成的代码 "
'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents label2 As System.Web.UI.WebControls.Label
Protected WithEvents label3 As System.Web.UI.WebControls.Label
Protected WithEvents label4 As System.Web.UI.WebControls.Label
Protected WithEvents label5 As System.Web.UI.WebControls.Label
Protected WithEvents label6 As System.Web.UI.WebControls.Label
Protected WithEvents txtshou As System.Web.UI.WebControls.TextBox
Protected WithEvents fname As System.Web.UI.WebControls.TextBox
Protected WithEvents txtsub As System.Web.UI.WebControls.TextBox
Protected WithEvents femail As System.Web.UI.WebControls.TextBox
Protected WithEvents txtemail As System.Web.UI.WebControls.TextBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Label7 As System.Web.UI.WebControls.Label
Protected WithEvents Label8 As System.Web.UI.WebControls.Label
Protected WithEvents fj As System.Web.UI.WebControls.DropDownList
Protected WithEvents upfile As System.Web.UI.HtmlControls.HtmlInputFile
Protected WithEvents upload As System.Web.UI.WebControls.Button
Protected WithEvents delfile As System.Web.UI.WebControls.Button
Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm
Protected WithEvents RegularExpressionValidator1 As System.Web.UI.WebControls.RegularExpressionValidator
Protected WithEvents RegularExpressionValidator2 As System.Web.UI.WebControls.RegularExpressionValidator
Protected WithEvents RequiredFieldValidator1 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents RequiredFieldValidator2 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents RequiredFieldValidator3 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents Label9 As System.Web.UI.WebControls.Label
'注意: 以下占位符声明是 Web 窗体设计器所必需的。
'不要删除或移动它。
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mymessage As New MailMessage
Dim i As Integer
Dim attchments(fj.Items.Count) As String
Dim attchfile As MailAttachment
mymessage.From = femail.Text
mymessage.To = txtshou.Text
mymessage.Subject = txtsub.Text
mymessage.Body = txtemail.Text
mymessage.BodyFormat = MailFormat.Html
attchfile = New MailAttachment(upfile.PostedFile.FileName)
mymessage.Attachments.Add(attchfile)
For i = 0 To fj.Items.Count - 1
attchments(i) = fj.Items(i).Value
Next
SmtpMail.SmtpServer = "smtp.163.com"
SmtpMail.Send(mymessage)
Label7.Text = "你的信件已经成功的发送到了" + txtshou.Text
Page.RegisterClientScriptBlock("ok", "<script language=javascript>alert('发送成功')</script>")
End Sub
Private Sub upload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles upload.Click
If upfile.PostedFile.ContentLength <> 0 Then
Label7.Text = upfile.PostedFile.FileName
delfile.Visible = True
fj.Visible = True
fj.Items.Add(upfile.PostedFile.FileName)
End If
Page.RegisterClientScriptBlock("ok", "<script language=javascript>alert('上传成功')</script>")
End Sub
End Class