Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to find out, if FSO created and saved a file?
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
How to find out, if FSO created and saved a file?
Divers
Thread ID:
00770830
Message ID:
00770830
Vues:
48
Here is a post from another forum with the problem, I found interesting:
========================================================================
I have an asp page that is writing an excel file that is subsequently being attached to some emails. As it stands, the file gets attached, but is empty since the save has not completed. How can I make sure that the save is complete prior to the email loop?

The email attachments are empty (they are an excel file with the correct title - but blank).
    with objCmd
        .commandText = "br_sp_threeDayReport"
        .CommandType = &H0004
    End With
    
    set objrs = objcmd.execute()
    recCount = 0
    
    do while not objrs.eof
        if lcase(objrs("created")) <> "null" then
            if lastName <> "" then
                recCount = recCount + 1
                if lastName <> objrs("lastName") then strOut = strOut & "<tr></tr>"    '<
            end if
            lastName = objrs("lastName")
        end if
        strOut = strOut & objrs(0)
        objrs.movenext
    loop
    
    if recCount > 0 then         '    <'records found'
    
        Set act = fso.CreateTextFile(server.mappath(g_filename), true)
        with act
            .WriteLine "<html xmlns:x=""urn:schemas-microsoft-com:office:excel"">"
            .WriteLine "<head>"
            .WriteLine "<!--[if gte mso 9]><xml>"
            .WriteLine "<x:ExcelWorkbook>"
                .WriteLine "<x:ExcelWorksheets>"
                    .WriteLine "<x:ExcelWorksheet>"
                    .WriteLine "<x:Name>Items Over 3 Days Old</x:Name>"
                        .WriteLine "<x:WorksheetOptions>"
                            .WriteLine "<x:PageSetup>"
                                .WriteLine "<x:Header>BRTT Active Requests Over 3 Days Old</x:Header>"
                            .WriteLine "</x:PageSetup>"
                            .WriteLine "<x:Print>"
                                .WriteLine "<x:ValidPrinterInfo/>"
                            .WriteLine "</x:Print>"
                        .WriteLine "</x:WorksheetOptions>"
                    .WriteLine "</x:ExcelWorksheet>"
                .WriteLine "</x:ExcelWorksheets>"
            .WriteLine "</x:ExcelWorkbook>"
            .WriteLine "</xml>"
            .WriteLine "<![endif]--> "
            .WriteLine "</head>"
            .WriteLine strOut
        end with    
        act.close


        'now mail them'
                
        strSQL = "SELECT firstName, email "&_
            "FROM tblPerson p JOIN tbmPersonRole r on p.personID = r.personID "&_
            "WHERE r.roleID = (select roleID from tblRole where roleName='Administrator')"
        set objrs = objconn.execute(strSQL)

        do while not objrs.eof
            set objMail = server.createObject("CDONTS.newMail")
            with objMail
                .From = "joeblow@abc.com"
                .To =  objrs("email")
                .Subject =  "Daily Report - Requests Over 3 days Old"
                strOut = objrs("firstName") &_
                        ", <br><br>Your daily report for BRTT requests over 3 days old (starting 3/24/03) is attached.<br>"&_
                        "The total number of records found is " & recCount & ".<br><br><br>"
                .Body =  strOut
                .AttachFile (server.mappath(g_filename ))
                .bodyFormat = 0        'HTML'
                .mailFormat = 0        'MIME Format'        
                .send
            end with
            objrs.movenext
        loop
    end if     'records found'  
I suggested to put a loop until file size greater than 0, but it didn't help. Any other ideas?

Thanks.
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform