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


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

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

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


加好友 发短信
等级:幼狐 帖子:142 积分:1649 威望:0 精华:0 注册:2014/5/3 14:52:00
[求助]请教邮件发送成功与否提示如何实现  发帖心情 Post By:2015/6/27 18:18:00 [只看该作者]

http://www.foxtable.com/help/index.html?n=2686.htm

 

请问如何把下列代码加入


    MessageBox.Show("发送成功!","提示", MessageBoxButtons.OK, MessageBoxIcon.Information)

Else

    MessageBox.Show("发送失败!","提示", MessageBoxButtons.OK, MessageBoxIcon.Warning)

[此贴子已经被作者于2015/6/27 18:41:48编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | 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

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | 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)


 回到顶部
帅哥哟,离线,有人找我吗?
李孝春
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2472 积分:17346 威望:0 精华:0 注册:2013/1/31 0:03:00
回复:(大红袍)mark 处理异步发送邮件 全局...  发帖心情 Post By:2019/2/11 10:51:00 [只看该作者]


图片点击可在新窗口打开查看此主题相关图片如下:11.png
图片点击可在新窗口打开查看
大红袍老师,我在运行过程中出现这个错误,可以帮忙看看怎么解决么?

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | 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


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | 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)


 回到顶部
帅哥哟,离线,有人找我吗?
李孝春
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2472 积分:17346 威望:0 精华:0 注册:2013/1/31 0:03:00
回复:(有点甜)异步发送 Dim client As Ne...  发帖心情 Post By:2019/2/11 12:20:00 [只看该作者]

OK  谢谢有点甜老师

 回到顶部