Extremely basic VB oddness



  • Can anyone clue me in on why the following snippet wouldn't work? The
    file definitely exists - I know because elsewhere I "put" to it and I
    copied the Open line directly from that bit of code. Also the file
    definitely has contents (I checked with notepad). And yet the msgbox
    that pops up is empty. No exceptions being thrown or anything afaict.



    k = FreeFile

    Open "c:\outlooklog.txt" For Binary As #k

    Get #k, , htmlbodystr

    Close #k

    MsgBox htmlbodystr



    For the record, the code I used to write to the file looks like:



    Set myitem = Application.CreateItem(olMailItem)

    myitem.Display

    Open "c:\outlooklog.txt" For Binary As #1

    Put #1, , CStr(myitem.HTMLBody)

    Close #1



    This is using VBA in Outlook (god help me :()



  • Add before the Get:



    HtmlBodyString = String([max size of buffer], " ")






  • Woo! Thanks muchly.






  • @Mike R said:

    Add before the Get:

    HtmlBodyString = String([max size of buffer], " ")


    I would've used: HtmlBodyString = String(Lof(k), " ") [;)]



  • @RobIII said:

    @Mike R said:

    Add before the Get:

    HtmlBodyString = String([max size of buffer], " ")


    I would've used: HtmlBodyString = String(Lof(k), " ") [;)]



    Hmmph.


Log in to reply