标题:[求助]
取消只看楼主
yuxinlang
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2005-11-30
 问题点数:0 回复次数:0 
[求助]

帮忙看一下
SmtpMail.SmtpServer = Trim(TextBox5.Text)
Try
Smtpmail.Send(mail)

有什么错误

Imports System

Imports System.Web

Imports System.Web.Mail

Imports System.Data

Imports System.Drawing

Imports System.Collections

Imports System.Windows.Forms

Imports System.ComponentModel

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows 窗体设计器生成的代码 "

Public Sub New()
MyBase.New()

'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()

'在 InitializeComponent() 调用之后添加任何初始化

End Sub

'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer

'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents RichTextBox1 As System.Windows.Forms.RichTextBox
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.Label5 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.TextBox4 = New System.Windows.Forms.TextBox
Me.TextBox5 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.RichTextBox1 = New System.Windows.Forms.RichTextBox
Me.Button3 = New System.Windows.Forms.Button
Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("宋体", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label1.Location = New System.Drawing.Point(24, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(64, 16)
Me.Label1.TabIndex = 0
Me.Label1.Text = "邮件发送"
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("宋体", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label2.Location = New System.Drawing.Point(16, 64)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(72, 16)
Me.Label2.TabIndex = 1
Me.Label2.Text = "收件人地址"
'
'Label3
'
Me.Label3.Font = New System.Drawing.Font("宋体", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label3.Location = New System.Drawing.Point(32, 104)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(56, 16)
Me.Label3.TabIndex = 2
Me.Label3.Text = " 抄 送"
'
'Label4
'
Me.Label4.Font = New System.Drawing.Font("宋体", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label4.Location = New System.Drawing.Point(24, 144)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(64, 16)
Me.Label4.TabIndex = 3
Me.Label4.Text = "邮件主题"
'
'Label5
'
Me.Label5.Font = New System.Drawing.Font("宋体", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label5.Location = New System.Drawing.Point(16, 184)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(72, 16)
Me.Label5.TabIndex = 4
Me.Label5.Text = "STMP服务器"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(120, 24)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(192, 22)
Me.TextBox1.TabIndex = 5
Me.TextBox1.Text = ""
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(120, 64)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(192, 22)
Me.TextBox2.TabIndex = 6
Me.TextBox2.Text = ""
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(120, 104)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(192, 22)
Me.TextBox3.TabIndex = 7
Me.TextBox3.Text = ""
'
'TextBox4
'
Me.TextBox4.Location = New System.Drawing.Point(120, 144)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.Size = New System.Drawing.Size(192, 22)
Me.TextBox4.TabIndex = 8
Me.TextBox4.Text = ""
'
'TextBox5
'
Me.TextBox5.Location = New System.Drawing.Point(120, 184)
Me.TextBox5.Name = "TextBox5"
Me.TextBox5.Size = New System.Drawing.Size(192, 22)
Me.TextBox5.TabIndex = 9
Me.TextBox5.Text = ""
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(16, 416)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 11
Me.Button1.Text = "发 送"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(128, 416)
Me.Button2.Name = "Button2"
Me.Button2.TabIndex = 12
Me.Button2.Text = "附 件"
'
'RichTextBox1
'
Me.RichTextBox1.Location = New System.Drawing.Point(0, 224)
Me.RichTextBox1.Name = "RichTextBox1"
Me.RichTextBox1.Size = New System.Drawing.Size(336, 168)
Me.RichTextBox1.TabIndex = 13
Me.RichTextBox1.Text = ""
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(248, 416)
Me.Button3.Name = "Button3"
Me.Button3.TabIndex = 14
Me.Button3.Text = "清 空"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(7, 15)
Me.ClientSize = New System.Drawing.Size(344, 454)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.RichTextBox1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox5)
Me.Controls.Add(Me.TextBox4)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Font = New System.Drawing.Font("宋体", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Name = "Form1"
Me.Text = "邮件发送"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
RichTextBox1.Text = ""


End Sub
Dim mail As New MailMessage
Dim Smtpmail As New MailMessage

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

mail.From = Trim(TextBox1.Text)
mail.To = Trim(TextBox2.Text)
mail.Cc = Trim(TextBox3.Text)
mail.Subject = Trim(TextBox4.Text)
mail.body = Trim(RichTextBox1.Text)
SmtpMail.SmtpServer = Trim(TextBox5.Text)
Try
Smtpmail.Send(mail)
Catch ex As Exception
MessageBox.Show(ex.Message)

End Try
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If OpenFileDialog1.ShowDialog = DialogResult.OK Then
mail.Attachments.Add(Trim(OpenFileDialog1.FileName))

End If
End Sub
End Class

搜索更多相关主题的帖子: System Imports Forms Windows 
2005-12-10 21:53



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-37708-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.175031 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved