Results 1 to 4 of 4

Thread: open txt files hm

  1. #1
    nzer
    Guest

    Angry open txt files hm

    Hi,

    i want to open a txt file (could be quite large) and read all the txt from it so i can use my program to email it.. I have the emailing side sorted.. just need to work out how to open my file and send it as txt

    Thanks!

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Here's a quick way of getting the entire file into a variable.

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.     Dim fileContents As String
    5.     Open "c:\autoexec.bat" For Binary As #1
    6.         fileContents = Input(LOF(1), 1)
    7.     Close #1
    8.     MsgBox fileContents
    9. End Sub
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Instead of opening and reading the file, if you want to EMail the contents, wouldn't it be simpler to just programmatically attach the file to an EMail message?

  4. #4
    nzer
    Guest

    but...

    i don't know how to do that with the code i have.. this is easier :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width