# Read text file into variable

**URL:** https://www.finalbuilder.com/forums/t/read-text-file-into-variable/114
**Category:** Discussion
**Created:** [June 20, 2006, 10:40am UTC](https://www.finalbuilder.com/forums/t/read-text-file-into-variable/114 "2006-06-20T10:40:33Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 20, 2006, 10:40am UTC](https://www.finalbuilder.com/forums/t/read-text-file-into-variable/114/1 "2006-06-20T10:40:33Z")

</div>

I am trying to read a text file into a variable, then output the variable in the email body as HTML.

%var%  
  
But i found that it always print everything into one line, even though the text file content has several lines. Is there anything i can do to have proper formmating?  
Thanks

---

<div class="post-metadata">

### Author: ![angus](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@angus](https://www.finalbuilder.com/forums/u/angus)
#### Post date: [June 21, 2006, 1:41am UTC](https://www.finalbuilder.com/forums/t/read-text-file-into-variable/114/2 "2006-06-21T01:41:23Z")

</div>

Seems to work for me (I read a multiline text file into a variable, then displayed the variable in a MessageBox action.)  
  
Is it possible that the action you are using to view the variable is not allowing you multiple lines? How are you using the variable data?

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 22, 2006, 3:33am UTC](https://www.finalbuilder.com/forums/t/read-text-file-into-variable/114/3 "2006-06-22T03:33:39Z")

</div>

Thanks for the reply.  
  
Yes, i tried using message box, it works fine.   
What i am trying to do is:  
- Run .exe, output result to a text file  
- Read text file into a variable  
- Send Email with HTML formmatted message, in the body of the email, i'll use the variable like this:

  
%VAR%  
  
  
Am i missing something? or any workaround? Thanks

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 22, 2006, 3:34am UTC](https://www.finalbuilder.com/forums/t/read-text-file-into-variable/114/4 "2006-06-22T03:34:53Z")

</div>

I mean i’ll have  
TR tag  
TD tag %VAR%   
close TD tag  
close TR tag

---

<div class="post-metadata">

### Author: ![angus](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@angus](https://www.finalbuilder.com/forums/u/angus)
#### Post date: [June 23, 2006, 2:00am UTC](https://www.finalbuilder.com/forums/t/read-text-file-into-variable/114/5 "2006-06-23T02:00:28Z")

</div>

Hi Sherry,  
  
HTML doesn’t respect newlines, it ignores all whitespace.  
  
To work around the problem, replace all the newlines with BRs. An easy way to do this is to put the following JScript into the BeforeAction event of the Send Email action:  
  
VAR=VAR.replace(/\n/g,‘BRTag’);  
  
(BRTag should be a BR html tag. The forum software has a bug which currently won’t let us escape \< and \> properly. Should be fixed soon, though.)

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 28, 2006, 3:12am UTC](https://www.finalbuilder.com/forums/t/read-text-file-into-variable/114/6 "2006-06-28T03:12:41Z")

</div>

Thanks for the reply. It's working.
