相当多的邮件服务器不支持大附件,一般为32MB,网易的是50MB。参照链接:
网站建设哪家好,找创新互联建站!专注于网页设计、网站建设、微信开发、微信小程序定制开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了淄川免费建站欢迎大家使用!
所以发送失败未必是你代码的问题。很有可能是你服务器的问题。请找一个支持大附件的邮箱试一试,找不到的话看能不能把附件拆到32M以下,然后多次发送。
Dim OpenFileDialog As New OpenFileDialog
OpenFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
OpenFileDialog.Filter = "文本文件(*.jpg)|*.jpg|所有文件(*.*)|*.*"
If (OpenFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then
Dim FileName As String = OpenFileDialog.FileName
' TODO: 在此处添加打开文件的代码。
textbox1.Text = FileName
End If
第一个按钮 上传
Dim filelast As String = fileaddbefore.Text.Substring(fileaddbefore.Text.LastIndexOf("."), fileaddbefore.Text.Length - fileaddbefore.Text.LastIndexOf("."))
MessageBox.Show(filelast)
My.Computer.Network.UploadFile(textbox1.Text, "" 文件名.Text filelast, "登录名1", "登录密码", True, 100)
第二个按钮
My.Computer.Network.UploadFile
比如上传到FTP
My.Computer.Network.UploadFile("d:\1.txt", "“, "FTP账号", "FTP密码", True, 100)
新手路过。
方法很多,vb.net很简单的比如: Form2窗体的Textbox2属性设置为public,在Form1点击button1.
Dim frm As New Form2
frm.TextBox2.Text = "123"
frm.ShowDialog() 可以取到form1里面窗体传的值
还有一种方法:From1 :
Dim frm As New Form2
frm.Owner = Me
frm.ShowDialog()
from2 : Private frmParent As Form1
frmParent = Me.Owner
Me.TextBox2.Text = frmParent.TextBox1.Text
Private Sub Command1_Click()
'下载文件:
Inet1.Execute "", "GET firewall.rsc 文件路径"
ri = Inet1.StillExecuting
Do While ri
ri = Inet1.StillExecuting
DoEvents
Loop
End Sub
Private Sub Command2_Click()
'上传文件:
Inet1.Execute "", "PUT d:\11.xls 11.xls"
ri = Inet1.StillExecuting
Do While ri
ri = Inet1.StillExecuting
DoEvents
Loop
End Sub
Private Sub Form_Load()
Inet1.Protocol = icFTP
Inet1.RemoteHost = "192.168.1.1" '服务器地址
Inet1.RemotePort = 21 'FTP端口
Inet1.UserName = "" '用户名
Inet1.Password = ""
End Sub
这个我测试通过