travisbrown
Technical User
- Dec 31, 2001
- 1,016
Okay. Biggish problem for an app that's in production.
I'm just trying to fix. Another developer wrote it, so forgive the messy code. I've reformatted it a bit for this post.
Here's the situation.
Files are uploaded to db as BLOBs, then attached to emails sent through CDO. The files upload fine, are streamed back to disk for download and attachment fine, but sometimes get corrupted when sent through CDO. has anyone seen this before? I've only noticed it on PDFs > 2mb so far.
I've followed the process path through and checked the files 1.before upload 2.after streamed back do disk for attachment through CDO 3. after FSO-moved to another directory. All are fine, but when I get the email, the file is corrupted. It's happening somewhere between send and receive. I've tested on several different W2k3 servers, all with the same result.
Here is the binary stream code and the cdo code. I don't see anything glaringly wrong, but maybe new eyes...C
I'm just trying to fix. Another developer wrote it, so forgive the messy code. I've reformatted it a bit for this post.
Here's the situation.
Files are uploaded to db as BLOBs, then attached to emails sent through CDO. The files upload fine, are streamed back to disk for download and attachment fine, but sometimes get corrupted when sent through CDO. has anyone seen this before? I've only noticed it on PDFs > 2mb so far.
I've followed the process path through and checked the files 1.before upload 2.after streamed back do disk for attachment through CDO 3. after FSO-moved to another directory. All are fine, but when I get the email, the file is corrupted. It's happening somewhere between send and receive. I've tested on several different W2k3 servers, all with the same result.
Here is the binary stream code and the cdo code. I don't see anything glaringly wrong, but maybe new eyes...C
Code:
<%
if Ubound(arrSelFiles) > 0 then
for iLoop = 0 to Ubound(arrSelFiles) - 1
strSql = "SELECT [file],[extension] FROM tblDistributionCorrespondence WHERE fid = " & strMaxId & " AND id = " & arrSelFiles(iLoop)
rsFileContent.open strSql,objConn,1
response.write strsql
If Not rsFileContent.EOF and strAttach <> "" Then
while not rsFileContent.EOF
strFileName= rsFileContent("extension")
sqlSendFile = "INSERT INTO tblSendFiles(sendID,fileAttached,fid) VALUES("
sqlSendFile = sqlSendFile & strMaxEmailSendID &",'" &strFileName & "'," & arrSelFiles(iLoop) & ")"
objConn.Execute(sqlSendFile)
strStream.Type = 1
strStream.Open
strStream.Write rsFileContent("file").Value
strStream.SaveToFile strFolder&"\"&strFileName,2
strAttachments = strFolder&"\"&strFileName
obj_Mail.AddAttachment strAttachments
iCount = iCount + 1
strStream.close
rsFileContent.moveNext
wend
End If
rsFileContent.Close
'Set rsFileContent = Nothing
next
End if
obj_Mail.From = "emailtest@email.com"
obj_Mail.subject = strHeader
obj_Mail.HTMLBody = strFooter
sqlApplication = "SELECT DISTINCT tblContact.id,email FROM "
sqlApplication = sqlApplication & " (((tblDistribution LEFT JOIN tblDistributionContact "
sqlApplication = sqlApplication & " ON tblDistribution.[id] = tblDistributionContact.fid)"
sqlApplication = sqlApplication & " INNER JOIN tblContact ON tblContact.[id] = tblDistributionContact.contact_id)"
sqlApplication = sqlApplication & " INNER JOIN tblContactEmail ON tblContact.[id] = tblContactEmail.fid)"
sqlApplication = sqlApplication & " INNER JOIN tblContactDeliveryMode ON tblContactDeliveryMode.fid = tblContact.[id]"
sqlApplication = sqlApplication & " WHERE tblDistribution.[id] = "& strMaxId & " AND authUser='"& request.querystring("vuser")& "'"
sqlApplication = sqlApplication & " AND tblContactDeliveryMode.mode = 1"
rstApplication.open sqlApplication,objConn,1
if not rstApplication.EOF then
recips = "emailtest@email.ca"
while not rstApplication.EOF
strName = rstApplication("id")
strToEmail = rstApplication("Email")
sqlSendRecipients = "INSERT INTO tblEmailRecipients(sendID,RecipientEmail,Recipient) VALUES("
sqlSendRecipients = sqlSendRecipients & strMaxEmailSendID & ",'" & strToEmail & "','" & strName & "')"
'response.write sqlSendRecipients
recips = recips & ";" & rstApplication("Email")
objConn.Execute(sqlSendRecipients)
rstApplication.moveNext
wend
obj_Mail.To = recips
obj_Mail.Send
end if
%>