我的源码如下:
Private Function jmailsend() As Boolean
Try
Dim jmail1 As New jmail.Message
jmail1.ContentType = "text/html"
jmail1.Encoding = "base64"
jmail1.Charset = "GB2312"
jmail1.MailServerUserName = MailUserName '用户名
jmail1.MailServerPassWord = MailUserPass '密码
jmail1.From = Me.txtMailAdd.Text '发件人邮件地址
jmail1.Subject = "来自 [" & MailBoxName & "]" & Me.txtName.Text & " 的邮件" '邮件的标题
jmail1.AddRecipient(MailAddress)
jmail1.Body = Me.txtContext.Text '邮件的内容
'附件信息
Dim strAddFileName As String
strAddFileName = UpAddFile()
If strAddFileName <> "" Then
jmail1.AddAttachment(strAddFileName, False, "")
End If
jmail1.Send(MailSMTPServer, False)
jmail1.Close()
jmail1 = Nothing
Return True
Catch ex As Exception
Me.labMess.Text = "错误:" & ex.Message
Return False
End Try
End Function