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


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

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

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/6/28 9:58:00 [显示全部帖子]

try
    Dim m As New MailSender
    m.Host = "smtp.21cn.net"
    m.Account = "xiaoliu"
    m.Password = "xiaoliu1234567"
    m.From = "xiaoliu@Sina.com.cn"
    m.To = "meili@Sina.com.cn"
    m.Title = "李总明天来北京"
    m.C
    m.Send()
    msgbox("发送成功")
catch ex As exception
    msgbox("没发成功")
End try

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/6/28 10:02:00 [显示全部帖子]

mark 处理异步发送邮件

 

全局代码处理

 

Public Sub SendCompletedCallback(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)
' Get the unique identifier for this asynchronous operation.
Dim token As String = CStr(e.UserState)

If e.Cancelled Then
    output.show("[" & token & "] Send canceled.")
End If
If e.Error IsNot Nothing Then
    output.show("[{" & token & "}] {" & e.Error.ToString() & "}" )
Else
    output.show("Message sent.")
End If

End Sub

 

 

发送代码

 

Dim client As New Net.Mail.SmtpClient("smtp.126.com")
'client.Timeout = 60000

client.UseDefaultCredentials = True
client.Credentials = new System.Net.NetworkCredential("lin_hailun@126.com", "6849338.")
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network

Dim [from] As New Net.Mail.MailAddress("lin_hailun@126.com", "lin " & ChrW(&HD8) & " hailun", System.Text.Encoding.UTF8)
' Set destinations for the e-mail message.
Dim [To] As New Net.Mail.MailAddress("2450314695@qq.com")
' Specify the message content.
Dim message As New Net.Mail.MailMessage([from], [To])

message.Body = "This is a test e-mail message sent by an application. "
' Include some non-ASCII characters in body and subject.
Dim someArrows As New String(New Char() {ChrW(&H2190), ChrW(&H2191), ChrW(&H2192), ChrW(&H2193)})
message.Body += Environment.NewLine & someArrows
message.BodyEncoding = System.Text.Encoding.UTF8
message.Subject = "test message 1" & someArrows
message.SubjectEncoding = System.Text.Encoding.UTF8
' Set the method that is called back when the send operation ends.
AddHandler client.SendCompleted, AddressOf SendCompletedCallback

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


 回到顶部