简体   繁体   中英

How to put entire txt file content inside one variable

I have a generated report stored in a .txt file, which I need to put inside an email body.

I tried to use for the email, but we have security software which prevents it's use. I need therefore to use

I tried this , but it doesn't work:

set /P file=<<Result.txt
start "" "mailto:mail@gmail.com?subject=test&body=%file%"

Work in progress.

Have you tested if the file even goes into variable? I can see a small typo in your code. I've just tested and it should be

set /P file=<Result.txt

Second problem is: it reads only the first line. It can be helped with this:

SetLocal EnableDelayedExpansion

set file=
for /f "delims=" %%i in (Result.txt) do set file=!file! %%i

start "" "mailto:mail@gmail.com?subject=test&body=%file%"
EndLocal

But it will write everything in one line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM