내가 VBScript를의 메시지 본문을 지원하는 txt 파일을 만든하지만 그것은 단지VBScript를
WScript.Sleep 100
Set WshShell=WScript.CreateObject("WScript.Shell")
Set objShell=WScript.CreateObject("WScript.Shell")
set objOutlook=CreateObject("Outlook.Application")
Set objMail=CreateObject("CDO.Message")
Set objMail=objOutlook.CreateItem(0)
strDesktop = WshShell.SpecialFolders("Desktop")
Set objFileToReadTo = CreateObject("Scripting.FileSystemObject").OpenTextFile(strDesktop + "\\send email with attachment\List_To.txt",1)
Set objFileToReadCC = CreateObject("Scripting.FileSystemObject").OpenTextFile(strDesktop + "\\send email with attachment\List_CC.txt",1)
Set objFileToReadSubject = CreateObject("Scripting.FileSystemObject").OpenTextFile(strDesktop + "\\send email with attachment\List_Subject.txt",1)
Set objFileToReadBody = CreateObject("Scripting.FileSystemObject").OpenTextFile(strDesktop + "\\send email with attachment\Email Body.txt",1)
Set objFileToReadAttachments = CreateObject("Scripting.FileSystemObject").OpenTextFile(strDesktop + "\\send email with attachment\List_Attachments_withFileExtension.txt",1)
Dim strLineTo
Dim strLineCC
Dim strLineSubject
Dim strLineBody
Dim strLineAttachments
objMail.Display
WScript.Sleep 10
do while not objFileToReadTo.AtEndOfStream
strLineTo = objFileToReadTo.ReadLine()
objMail.To=strLineTo
loop
objFileToReadTo.Close
WScript.Sleep 10
do while not objFileToReadCC.AtEndOfStream
strLineCC = objFileToReadCC.ReadLine()
objMail.cc = strLineCC
loop
objFileToReadCC.Close
'41
WScript.Sleep 10
do while not objFileToReadSubject.AtEndOfStream
strLineSubject = objFileToReadSubject.ReadLine()
objMail.Subject = strLineSubject
loop
objFileToReadSubject.Close
'48
WScript.Sleep 10
do while not objFileToReadBody.AtEndOfStream
strLineBody = objFileToReadBody.ReadLine()
objMail.Body = strLineBody & vbCRLF
loop
objFileToReadBody.Close
'55
WScript.Sleep 10
do while not objFileToReadAttachments.AtEndOfStream
strLineAttachments = objFileToReadAttachments.ReadLine()
objMail.Attachments.Add(strLineAttachments)
loop
objFileToReadAttachments.Close
'62
'objShell.Sendkeys "%s"
WScript.Sleep 40
'objShell.SendKeys "{TAB}"
'objShell.SendKeys "{UP}"
'objShell.SendKeys "{Enter}"
'set MyEmail=nothing
'objOutlook.Quit
'Set objMail = Nothing
'Set objOutlook = Nothing
여기 인 messagebody.txt의 마지막 줄을 읽고 다음 내 messagebody.txt
Hi,
Testing vbscript
Regards,
abcd
마지막 ABCD 만 읽고 oulook 창에 표시합니다.
어떻게하면 여러 줄을 이해할 수 있습니까?
실제로 이유는 각 줄이 본문 텍스트를 대체하는 본문에 텍스트를 추가하지 않기 때문에 'ReadAll' 대신'objMail.Body = objMail.Body & strLineBody' 문제가 수정됩니다. – Lankymart
@Lankymart 그 밖의 무엇을 코드의 주석 부분에 썼습니까? 나는 각 readline 호출과 함께 기존 라인을 덮어 쓴다고 썼다. 따라서 모든 내용을 포함시키는 더 좋은 방법은 readAll 메서드를 한 번에 사용하여 전자 메일 본문에 저장하는 것입니다. 그게 뭐가 잘못 됐니? – Gurman
더 좋은 방법은'ReadAll'을 사용하여 각 줄을 추가하는 것입니다. 특히 텍스트 요구 사항이 크기가 커질수록 비효율적입니다. – Lankymart