1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| Private Function TemplateCompress(ByVal aPath As String) As String Const ERR_SOURCE As String = "TemplateExtractor" On Error GoTo ERR_HANDLER: Dim xErrNum As Long, xErrMsg As String Dim bt() As Byte Dim f as Integer Dim vfname As String Dim rs As Object TemplateCompress = RESPONSE_CANCEL If Len(Dir(aPath, vbNormal)) < 1 Or Len(aPath) < 1 Then xErrMsg = "Failure to compress required email template to the database" GoTo EXIT_CLEANUP: End If
If InStrRev(aPath, "\") = Len(aPath) Then xErrMsg = "Failure to compress required email template to the database" GoTo EXIT_CLEANUP: End If
vfame = Mid(aPath, InStrRev(aPath, "\") + 1, Len(aPath) - InStrRev(aPath, "\") + 1)
f = FreeFile Open aPath For Binary Access Read As #f ReDim bt(0 To LOF(f) - 1) Get #f, , bt Close #f With CurrentDb Set rs = .OpenRecordset("SELECT * FROM CONTENT_TBL WHERE FILENAME = """ & vfname & """;") If Not (rs.BOF) Or Not (rs.EOF) Then rs.Edit rs![UPDATE_DT] = Now() rs![cdata] = bt rs.Update rs.Close TemplateCompress = RESPONSE_SUCCESS Else rs.Close Set rs = Nothing Set rs = .OpenRecordset("EMAILCONTENT_TBL") rs.AddNew rs![FileName] = vfname rs![cdata] = bt rs.Update rs.Close TemplateCompress = RESPONSE_SUCCESS End If End With Erase bt
EXIT_CLEANUP:
On Error Resume Next Sett rs = Nothing Exit Function ERR_HANDLER: Resume EXIT_CLEANUP:
End Function
|