I'm trying to use the code below to produce a CSV compatible file. The data is dragged from a recordset containing 2 columns: 'username' and 'EmailAddress'.
It creates the file ok but its not formatted correctly, Excel moans 'the file is not in a recognisable format' and then just opens it as a single column. Its because the 'username' and 'EmailAddress' column headers arent there and the thing isnt formatted:
strReturn = RSEmailAddrs.GetString(2,,",",vbCrLf,"")
Response.AddHeader "Content-Disposition", "attachment; filename=CSV_Mail_Export.csv"
Response.Charset = "UTF-8"
Response.ContentType = "text/plain"
How do i get this code to produce a 'proper' CSV file by dynamically including the DB column headers in the recordset and formatting it to keep Excel happy?
I've always done this sort of thing by looping through the RS and using FSO to physically create the file but this way looks loads neater.