发送邮件的实例: Private Sub SendMail() Dim mailSender As SmtpClient '邮件发送对象实例 Dim mailMsg As MailMessage '邮件信息实例 Dim mailFile As Attachment '附件实例 Dim mailAddressFrom As String '发信人邮箱地址 Dim mailPassword As String '邮箱密码 Dim mailTitle As String '邮件标题 Dim mailContent As String '邮件内容 Dim mailAddressTo As String '收信人邮箱地址 '变量初始化 mailAddressFrom = "From@163.com" '发信人邮箱地址 mailPassword = "Password" '邮箱密码 mailTitle = "title" '邮件标题 mailContent = "test" '邮件内容 mailAddressTo = "To@163.com" '收信人邮箱地址 Try '初始化邮件信息实例 mailMsg = New MailMessage( _ New MailAddress(mailAddressFrom), _ New MailAddress(mailAddressTo)) '设置邮件标题和邮件内容 mailMsg.Subject = mailTitle mailMsg.Body = mailContent '添加附件 mailFile = New Attachment("C:/boot.ini") mailMsg.Attachments.Add(mailFile) '初始化邮件发送对象实例 mailSender = New SmtpClient() '设置邮件参数 mailSender.Port = 25 '端口 mailSender.Host = "smtp.163.com" 'SMTP地址 mailSender.DeliveryMethod = SmtpDeliveryMethod.Network '发送方式 mailSender.Credentials = _ New System.Net.NetworkCredential(mailAddressFrom, mailPassword) '用户凭证 '发送邮件 mailSender.Send(mailMsg) MessageBox.Show("Sent successfully.") Catch ex As Exception MsgBox("Error:" & vbCrLf & ex.Message) End Try End Sub === 如果上面的内容对你有用,请随便回复点内容,谢谢!