VBScript ใส่รหัส protect file Excel และส่งอีเมล Outlook และแนบไฟล์ Excel พร้อมแสดงลายเซ็นอีเมลdtmYesterday = DateAdd("d", -1, Now())
theDate = Year(dtmYesterday) _
& Right(String(2,"0") & month(dtmYesterday ),2) _
& Right(String(2,"0") & Day(dtmYesterday ),2)
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.DisplayAlerts = False
Set objworkbook = objExcel.Workbooks.Open("C:\Users\xxxx\Desktop\test\sendmail\" & theDate & " test.xlsx")
objworkbook.SaveAs "C:\Users\xxxx\Desktop\test\sendmail\" & theDate & " test.xlsx", , "12345"
objworkbook.Close
' Set objworkbook = Nothing
objExcel.Quit
' Set objExcel = Nothing
Dim objOutl
Set objOutl = CreateObject("Outlook.Application")
Set objMailItem = objOutl.CreateItem(olMailItem)
'comment the next line if you do not want to see the outlook window
'objMailItem.Display
strEmailAddr = "test@test.com"
'strEmailAddrto = "test1@test.com"
'strEmailAddrcc = "test2@test.com"
Dim SigString
Dim Signature
Set oShell = CreateObject( "WScript.Shell" )
SigString = oShell.ExpandEnvironmentStrings("D:\Signatures\files\name.htm")
Dim fso
Dim ts
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(SigString).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
With objMailItem
.Display
.to = strEmailAddr
.CC = strEmailAddr
.Subject = "test"
.Attachments.Add "C:\Users\xxxx\Desktop\test\sendmail\" & theDate & " test.xlsx"
.HTMLBody = GetBoiler
End With
objMailItem.Send
Set objMailItem = nothing
Set objOutl = nothing
VBScript ใส่รหัส protect file Excel และส่งอีเมล Outlook และแนบไฟล์ Excel พร้อมแสดงลายเซ็นอีเมล
สิงหาคม 30, 2565
0 ความคิดเห็น