0
什麼和爲什麼?批量處理(SMTP)電子郵件多文件
我知道如何使用Blat。這不是問題。
已經使用Powershell和VBS完成了這項工作。但是,我的同事們已經要求我在批處理中重新執行此操作。
我們對VBS有企業安全限制,現在我們必須簽署所有的代碼。 Powershell是可以的,但...批量給我們一個很好的舊平臺,我們團隊中的每個人都能理解。
背景
我們正在讀爲企業和電子郵件列表的文件的mapping.txt。
試圖理清如何使用blat發送批處理文件來將一個或多個文件附加到電子郵件。
例如(注:下面列出的兩個文件的逗號):
-attach "20131208_Company_UsageReport.zip,20131208_Company_ActivityReport.zip"
我們看到處理附件以下
每BLAT的幫助(-h)開關:
----------------------- Attachment and encoding options -----------------------
-attach <file> : attach binary file(s) to message (filenames comma separated)
-attacht <file> : attach text file(s) to message (filenames comma separated)
-attachi <file> : attach text file(s) as INLINE (filenames comma separated)
-embed <file> : embed file(s) in HTML. Object tag in HTML must specify
content-id using cid: tag. eg: <img src="cid:image.jpg">
-af <file> : file containing list of binary file(s) to attach (comma separated)
-atf <file> : file containing list of text file(s) to attach (comma separated)
-aef <file> : file containing list of embed file(s) to attach (comma separated)
什麼我到目前爲止做了什麼? 借用 - How to concatenate variable with string or variable in batch file
SETLOCAL EnableDelayedExpansion
for /f "delims=" %%P in ('dir /b "C:\Batch\*Company*"') do (
SET "sZIPName=%%~nxP"
echo first stop
echo !sZIPName:~0,1!
IF "!sZIPName:~0,1!" NEQ "1" (SET "sZIPName=!sZIPName:~0,1!") && SET myvar=!myvar!%%P
IF "!sZIPName:~0,1!" EQU "1" (SET "sZIPName=!sZIPName:~0,1!") && SET myvar=!myvar!%%P
rem SET tempStr=GEN !sZIPName!
echo second stop
echo "!myvar! "
rem echo "!tempStr!"
rem echo "!sZIPName!"
pause
rem for /f "delims=" %%H in ('dir /b *.html') do (
rem IF "!sZIPName:~-0!"=="!%%H:~0,1!" echo %%H
rem)
)
我知道我能做到以下幾點:
IF "!sZIPName:~0,1!" NEQ "1" (SET "sZIPName=!sZIPName:~0,1!") && SET myvar=!myvar!%%P,
,但產生類似的結果:
"20131208_Company_UsageReport.zip,20131208_Company_ActivityReport.zip, "
太棒了!謝謝。工作很好,比我所做的要簡單得多。 – Leptonator