Foxtable(狐表)用户栏目专家坐堂 → [求助]请教邮件发送成功与否提示如何实现


  共有4723人关注过本帖树形打印复制链接

主题:[求助]请教邮件发送成功与否提示如何实现

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/2/11 11:33:00 [显示全部帖子]

同步发送

 

Dim client As New System.Net.Mail.SmtpClient("smtp.qq.com", 587) '或者465
client.EnableSsl = True 'SSL

client.Credentials = New System.Net.NetworkCredential("455189993@qq.com", "helen6849338.")
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network
Dim message As New System.Net.Mail.MailMessage()

message.From = new System.Net.Mail.MailAddress("455189993@qq.com","别名")

'message.To.Add(new System.Net.Mail.MailAddress("2450314695@qq.com","人名"))
message.To.Add("2450314695@qq.com")
message.Subject = "邮件测试"
message.BodyEncoding = System.Text.Encoding.UTF8

Dim content As String

content &= "这是文字" & vbcrlf
content &= "也是文字"

message.Body = content

Try
    client.Send(message)
    msgbox("发送成功")
Catch ex As Exception
    msgbox("发送失败:" & ex.message)
End Try


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/2/11 11:35:00 [显示全部帖子]

异步发送

 

Dim client As New System.Net.Mail.SmtpClient("smtp.qq.com", 587) '或者465
client.EnableSsl = True 'SSL

client.Credentials = New System.Net.NetworkCredential("455189993@qq.com", "helen6849338.")
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network
Dim message As New System.Net.Mail.MailMessage()

message.From = new System.Net.Mail.MailAddress("455189993@qq.com","别名")

'message.To.Add(new System.Net.Mail.MailAddress("2450314695@qq.com","人名"))
message.To.Add("2450314695@qq.com")
message.Subject = "邮件测试"
message.BodyEncoding = System.Text.Encoding.UTF8

Dim content As String

content &= "这是文字" & vbcrlf
content &= "也是文字"

message.Body = content

AddHandler client.SendCompleted, AddressOf SendCompletedCallback

Dim userState As String = "test message1"
client.SendAsync(message, userState)


 回到顶部