如何用VB将将一段代码写入txt

wwwyi13cn 2009-02-06 09:07:36
用VB创建一个TXT文本,然后写入以下代码?


Function MyCalc()

NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
Set Email = CreateObject("CDO.Message")
Email.From =From
Email.To =toEmail
Email.Subject =Subject
Email.Textbody =Textbody
Email.AddAttachment AddAttachment
With Email.Configuration.Fields
.Item(NameSpace&"sendusing") = 2
.Item(NameSpace&"smtpserver") = smtpserver
.Item(NameSpace&"smtpserverport") = 25
.Item(NameSpace&"smtpauthenticate") = 1
.Item(NameSpace&"sendusername") =sendusername
.Item(NameSpace&"sendpassword") =sendpassword
.Update
End With
Email.Send
end function
...全文
110 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wwwyi13cn 2009-02-06
  • 打赏
  • 举报
回复
非常有意思。
xrongzhen 2009-02-06
  • 打赏
  • 举报
回复
LZ,不明白你想干什么,仅仅是用代码把它输入到txt文件?没啥意义啊,就是最基本的
SYSSZ 2009-02-06
  • 打赏
  • 举报
回复
& "With Email.Configuration.Fields" & vbCrLf _
& "With Email.Configuration.Fields" & vbCrLf _
& "With Email.Configuration.Fields" & vbCrLf _
& "With Email.Configuration.Fields" & vbCrLf _
& "With Email.Configuration.Fields" & vbCrLf _
& "With Email.Configuration.Fields" & vbCrLf _
& "With Email.Configuration.Fields" & vbCrLf _
只要一行,粘多了
SYSSZ 2009-02-06
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Dim s As String
s = "Function MyCalc() " & vbCrLf _
& "NameSpace =" & """" & "http://schemas.microsoft.com/cdo/configuration/" & """" & vbCrLf _
& "Set Email = CreateObject(" & """" & "CDO.Message" & """" & ")" & vbCrLf _
& "Email.From = From " & vbCrLf _
& "Email.To = toEmail" & vbCrLf _
& "Email.Subject = Subject" & vbCrLf _
& "Email.Textbody = Textbody " & vbCrLf _
& "Email.AddAttachment AddAttachment " & vbCrLf _
& "With Email.Configuration.Fields" & vbCrLf _
& "With Email.Configuration.Fields" & vbCrLf _
& "With Email.Configuration.Fields" & vbCrLf _
& "With Email.Configuration.Fields" & vbCrLf _
& "With Email.Configuration.Fields" & vbCrLf _
& "With Email.Configuration.Fields" & vbCrLf _
& "With Email.Configuration.Fields" & vbCrLf _
& ".Item(NameSpace&" & """" & "sendusing" & """" & ") = 2" & vbCrLf _
& ".Item(NameSpace&" & """" & "smtpserver" & """" & ") = smtpserver" & vbCrLf _
& ".Item(NameSpace&" & """" & "smtpserverport" & """" & ") = 25" & vbCrLf _
& ".Item(NameSpace&" & """" & "smtpauthenticate" & """" & ") = 1" & vbCrLf _
& ".Item(NameSpace&" & """" & "sendusername" & """" & ") =sendusername" & vbCrLf _
& ".Item(NameSpace&" & """" & "sendpassword" & """" & ") =sendpassword" & vbCrLf _
& ".Update" & vbCrLf _
& "End With" & vbCrLf _
& "Email.Send" & vbCrLf _
& "end function" & vbCrLf
Open "C:\001.txt" For Output As #1
Print #1, s
Close #1
End Sub

1,065

社区成员

发帖
与我相关
我的任务
社区描述
VB 资源
社区管理员
  • 资源
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧