Jmail 发送程序,格式化日期时间,FSO文件操作

<%
 
'参数说明
  'Subject     : 邮件标题
  'MailAddress : 发件服务器的地址,如smtp.163.com
  'Email       : 收件人邮件地址
  'Sender      : 发件人姓名
  'Content     : 邮件内容
  'Fromer      : 发件人的邮件地址

 
Sub SendAction(subject, mailaddress, email, sender, content, fromer)
     
Set jmail = Server.CreateObject("JMAIL.SMTPMail")   '创建一个JMAIL对象
      jmail.silent = true   'JMAIL不会抛出例外错误,返回的值为FALSE跟TRUE
      jmail.logging = true   '启用使用日志
      jmail.Charset = "GB2312"  '邮件文字的代码为简体中文
      jmail.ContentType = "text/html"  '邮件的格式为HTML的
      jmail.ServerAddress =mailaddress  '发送邮件的服务器
      jmail.AddRecipient Email    '邮件的收件人
      jmail.SenderName = sender   '邮件发送者的姓名
      jmail.Sender = fromer    '邮件发送者的邮件地址
      jmail.Priority = 1   '邮件的紧急程序,1 为最快,5 为最慢, 3 为默认值
      jmail.Subject = subject  '邮件的标题
      jmail.Body = content   '邮件的内容
      '由于没有用到密抄跟抄送,这里屏蔽掉这两句,如果您有需要的话,可以在这里恢复
      'jmail.AddRecipientBCC Email   '密件收件人的地址
      'jmail.AddRecipientCC Email   '邮件抄送者的地址
      jmail.Execute()   '执行邮件发送
if JMailerror then
response.write
"发送成功!"
else
response.write JMailerror
end if
      jmail.Close   
'关闭邮件对象
  End Sub
 
 
'调用此Sub的例子

 
Call SendAction (strSubject,strMailaddress,strEmail,strSender,strContent,strFromer)

%
>

 ============================================
' 格式化日期时间(显示)
' 参数:n_Flag
' 1:"yyyy-mm-dd hh:mm:ss"
' 2:"yyyy-mm-dd"
' 3:"hh:mm:ss"
' 4:"yyyy年mm月dd日"
' 5:"yyyymmdd"
' 6:"yyyymmddhhmmss"
' 7:"yy-mm-dd" 
' 8:"yy-mm-dd hh:mm:ss"
' 9:"yyyy年mm月"
' 10:"mm/dd/yyyy"
' ============================================
Function Format_Time(s_Time, n_Flag)
Dim y, m, d, h, mi, s
Format_Time = ""
If IsDate(s_Time) = False Then Exit Function
y = cstr(year(s_Time))
if y = "1900" then Exit Function
m = right("0"&month(s_Time),2)
d = right("0"&day(s_Time),2)
h = right("0"&hour(s_Time),2)
mi = right("0"&minute(s_Time),2)
s = right("0"&second(s_Time),2)

Select Case n_Flag
Case 1
Format_Time = y & "-" & m & "-" & d & " " & h & ":" & mi & ":" & s
Case 2
Format_Time = y & "-" & m & "-" & d
Case 3
Format_Time = h & ":" & mi & ":" & s
Case 4
Format_Time = y & "年" & m & "月" & d & "日"
Case 5
Format_Time = y & m & d
case 6
Format_Time= y & m & d & h & mi & s
case 7
Format_Time= right(y,2) & "-" & m & "-" & d
case 8
Format_Time= right(y,2) & "-" & m & "-" & d & " " & h & ":" & mi & ":" & s
Case 9
Format_Time = y & "年" & m & "月"
Case 10
Format_Time = m & "/" & d & "/" & y & "/"
End Select
End Function

'==================================================
'
函数名:BuildFolder
'
作  用:创建文件夹
'
参  数:path ----------要创建的文件夹(路径)
'
==================================================
function BuildFolder(path)
Set fso = Server.CreateObject("Scripting.FileSystemObject")
    fso.CreateFolder(Server.MapPath(path))
    fso.Close
   
Set fso=Nothing
End Function
'==================================================
'
函数名:Buildfile
'
作  用:创建文件
'
参  数:Htmlcode ------要创建的文件信息
'
参  数:filex ----------要创建的文件名(路径)
'
==================================================
function Buildfile(filex,Htmlcode)
Set fso = Server.CreateObject("Scripting.FileSystemObject")
   
Set html = fso.CreateTextFile(Server.MapPath(filex))
        html.WriteLine Htmlcode
        html.close
   
Set html=Nothing
    fso.Close
   
Set fso=Nothing
End Function
'==================================================
'
函数名:Savefile
'
作  用:修改文件
'
参  数:file_body ------要创建的文件信息
'
参  数:file_name ------要创建的文件名(路径)
'
参  数:Cset -----------定义要创建的文件编码
'
==================================================
Function Savefile(file_body,file_name,Cset)
Set OS=Server.CreateObject("ADODB.Stream")
        OS.Type
=2
        OS.Open
        OS.Charset
= Cset
        OS.Position
=OS.Size
        OS.WriteText
=file_body
        OS.SaveToFile Server.MapPath(file_name),
2
        OS.Close
Set OS=Nothing
End Function

'==================================================
'
函数名:DelFolder
'
作  用:删除文件夹
'
参  数:FolderPath ------要删除的文件夹路径
'
==================================================
Function DelFolder(FolderPath)
   
dim path
    path
=FolderPath
   
Set fso = Server.CreateObject("Scripting.FileSystemObject")
   
Set DeleteFolder = FSO.GetFolder(Server.MapPath(path))
    DeleteFolder.Delete
    fso.Close
   
Set fso=Nothing
    Response.Write(
"<script language=""Javascript"">alert(""文件夹已删除"");history.go(-1);</script>")
End Function
'==================================================
'
函数名:ChkFile
'
作  用:检索文件是否存在
'
参  数:FilePath ------要检索的文件路径
'
==================================================
Function ChkFile(FilePath)
   
dim path
    path
=Server.MapPath(FilePath)
   
Set fso=Server.CreateObject("Scripting.FileSystemObject")
   
If fso.FileExists(path) then
       ChkFile
="OK!"
   
Else
       ChkFile
="文件不存在"
   
End IF
    fso.Close
   
Set fso=Nothing
End Function

'==================================================
'
函数名:DelFile
'
作  用:删除文件
'
参  数:FilePath ------要删除的文件的路径
'
==================================================
Function DelFile(FilePath)
dim path
    path
=Server.MapPath(FilePath)
Set fso = Server.CreateObject("Scripting.FileSystemObject")
   
'用两种方法删除文件
    fso.DeleteFile(path)'第一种方法
    Set File= FSO.GetFile(path)'第二种方法
        File.Delete
    fso.Close
   
Set fso=Nothing
End Function

发布了16 篇原创文章 · 获赞 1 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/wvtjplh/article/details/3847027