Dim PostedFile As HttpPostedFile = Files(iFile)
Dim FileName, FileExtent As String
FileName = Serverpath &System.IO.Path.GetFileName(PostedFile.FileName)
If System.IO.Path.GetFileName(PostedFile.FileName) <>"" Then
FileName = System.IO.Path.GetFileName(PostedFile.FileName)
Dim Url As String = Me.Label1.Text.Trim &FileName
PostedFile.SaveAs(Serve
1.使用socket方式,通过tcp连接web服务器的80端口,发送http协议命令.来实现传输.但太底层.都需要自己来实现.不好,2.使用xmlhttp控件.vb使用他,快速简单,可以选择get/post方式
下面是使用的封装函数.
Function xmlread(url) As String ''用xml读网页文件
Set http = CreateObject("Microsoft.XMLHTTP")
http.open "post", url, False
http.setRequestHeader "Content-Type", "text/XML"
http.setRequestHeader "Content-Type", "gb2312"
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
http.send
If http.readyState = 4 Then
xmlread = Trim(bytes2BSTR(http.responseBody))
Else: xmlread = "error"
End If
Set http = Nothing
End Function
Function xmlpost(url, Form) As String '''用xml传网页表单数据
Set http1 = CreateObject("Microsoft.XMLHTTP")
http1.open "post", url, False
http1.setRequestHeader "Content-Type", "text/XML"
http1.setRequestHeader "Content-Type", "gb2312"
http1.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
http1.send Form
If http1.readyState <>4 Then
xmlpost = "error"
End If
Set http1 = Nothing
End Function
'无法打开地址,你可以用邮件发送你的文件,下面是163邮箱测试代码,有些邮箱服务器可能不支持。 Private Sub Command1_Click() Sendmail "主题", "内容", "c:\a.txt" End Sub Function Sendmail(Subject, Textbody, Attachment) Dim NameSpace As String NameSpace = " http://schemas.microsoft.com/cdo/configuration/" With CreateObject("CDO.Message") .From = "sendjmail@163.com" '你的邮箱地址 .To = "sendjmail@163.com" '要发往的地址(有效的邮件地址就行) .Subject = Subject '主题 .Textbody = Textbody '内容 If Dir(Attachment) <>"" And Attachment <>"" Then .AddAttachment Attachment '附件 .Configuration.Fields.Item(NameSpace &"sendusing") = 2 .Configuration.Fields.Item(NameSpace &"smtpserver") = "smtp.163.com" '发送邮件服务器 .Configuration.Fields.Item(NameSpace &"smtpserverport") = 25 .Configuration.Fields.Item(NameSpace &"smtpauthenticate") = 1 .Configuration.Fields.Item(NameSpace &"sendusername") = "sendjmail" '你的邮箱用户名 .Configuration.Fields.Item(NameSpace &"sendpassword") = "222" '你的密码 .Configuration.Fields.Update .Send End With End Function欢迎分享,转载请注明来源:内存溢出
评论列表(0条)