vb.net发邮件

Try

                Dim mail As New MailMessage
            mail.To = "wqiyuan@126.com"
            mail.From = "qi@126.com"
            ' mail.
            '  mail.From.

            mail.Subject = "progToemail11"

            mail.BodyFormat = MailFormat.Html
            mail.Body = "qiyuan123"


            '******************************
            Dim sFile As String = "E:\he.rar"

            Dim oAttch As MailAttachment = New MailAttachment(sFile, MailEncoding.Base64)

            mail.Attachments.Add(oAttch)     附件   
            '******************************
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1")
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username")
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password")
            SmtpMail.SmtpServer = "smtp126.com"
            SmtpMail.Send(mail)


            MessageBox.Show("发送邮件成功", "qiyuan")
        Catch ex As Exception

            MessageBox.Show(ex.ToString)


        End Try

posted on 2007-04-03 20:22  奇远  阅读(1258)  评论(1编辑  收藏  举报

导航