Foxtable(狐表)用户栏目专家坐堂 → [求助]邮箱发送大附件失败求助


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

主题:[求助]邮箱发送大附件失败求助

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


加好友 发短信
等级:六尾狐 帖子:1347 积分:9817 威望:0 精华:0 注册:2015/6/30 8:46:00
[求助]邮箱发送大附件失败求助  发帖心情 Post By:2019/11/13 11:05:00 [显示全部帖子]

这是一个困扰我好久的问题,我们一直需要发文件给供应商,做了个自动发文件的窗体,但文件(特别是彩盒原档),一个文件几百M的,经常发送失败;

刚购买了高级版,如果将延时时间加长,用多线程(异步函数的方式能不能实现)

 

Dim tb As Table = Tables("受控文件管理" & "_Table1")
Dim r As Row = tb.Current
e.Form.Controls("But生成内容").performclick
e.Sender.Enabled = False
Dim path As String,path1 As String

If r("发放形式") = "发放" Then
    If r.IsNull("电子档文件") = False Then path = (Vars("OAPath") & "文控中心\受控文件\" & r("文件种类") & "\电子文件\" &  r("电子档文件"))
    path1 = (Vars("OAPath") & "文控中心\受控文件\" & r("文件种类") & "\" & r("文件编号") & " " & r("文件名称") & ".pdf")
Else
    MessageBox.Show("不能发送已经回收的受控文件")
    Exit Sub
End If
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~?
e.Sender.Enabled = False
e.Form.Controls("PictureBox1").Visible = True
e.Form.Controls("LabSend").Visible = True
Application.DoEvents()

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~?
Dim client As New Net.Mail.SmtpClient("smtp.163.com")
client.Timeout = 120000 '延时设置
client.UseDefaultCredentials = True
client.Credentials = new System.Net.NetworkCredential("***", "***")
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network

Dim [from] As New Net.Mail.MailAddress("***@163.com", "电子厂 " & ChrW(&HD8) & " 采购部", System.Text.Encoding.UTF8)
Dim [To] As New Net.Mail.MailAddress(e.Form.Controls("Text_邮箱").text)

Dim message As New Net.Mail.MailMessage([from], [To])
message.cc.Add("*@163.com") '抄送
message.Body = e.Form.Controls("Txt_Content").text
message.Body += Environment.NewLine ' & someArrows
message.BodyEncoding = System.Text.Encoding.UTF8
message.Subject = e.Form.Controls("Txt_Title").text ' & someArrows
message.SubjectEncoding = System.Text.Encoding.UTF8

'~~~~~~~~~~~~~~~~~~~~ 发送附档文件~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim attachment As new  System.Net.Mail.Attachment(path1,  System.Net.Mime.MediaTypeNames.Application.Octet)
message.Attachments.Add(attachment)
Dim attachment1 As new  System.Net.Mail.Attachment(path,  System.Net.Mime.MediaTypeNames.Application.Octet)
message.Attachments.Add(attachment1)
AddHandler client.SendCompleted, AddressOf SendCompletedCallback
'~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim userState As String = e.Form.Controls("Txt_Title").text
client.SendAsync(message, userState)


 回到顶部