I am using the Internet Data Transfer Library to transfer images from web sites. The problem is the module does not release the images once they are written to the hard drive. It is set up to parse a string and find the link. It does that. It just won't let the images go
Sub Trim_Text()
On Error Resume Next
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strbody, strJpeg, strJpegEnd, strPhotoaddress, strPhotoString As String
Dim strMsg As String
Dim strslm As String
Dim strfrom As String
Dim oHTTP As [Mail Test].HTTP
Set db = CurrentDb
Set rs = db.OpenRecordset("Query1")
Set objHTTP = New [Mail Test].HTTP
Do
strbody = rs.Fields(0)
strfrom = InStr(1, strbody, "from")
strNumber = Mid(strbody, strfrom + 7, 10)
strJpeg = InStr(1, strbody, "View") + 6
strJpegEnd = InStr(strJpeg, strbody, ">")
strPhotoaddress = (strJpegEnd - strJpeg)
strPhotoString = Mid(strbody, strJpeg, strPhotoaddress)
strPhotoString = Trim(strPhotoString)
strMsg = InStr(1, strbody, "Message:") + 9
strmsg1 = InStr(strMsg, strbody, " ")
strslm = Mid(strbody, strMsg, strmsg1 - strMsg) + 0
strCustomerNumber = InStr(strmsg1 + 1, strbody, " ")
strCustomerNumber = Mid(strbody, strmsg1 + 1, strCustomerNumber - strmsg1)
With objHTTP
.HttpURL = strPhotoString
'.DestinationFile = stName
.PromptWithCommonDialog = False
If .FileExists Then .OverwriteTarget = True
If Not .IsConnected Then .DialDefaultNumber
.ConnectToHTTPHost
stPointer = .WriteHTTPDataToString
iHolder = InStr(1, stPointer, "/i/")
iHolderi = InStr(1, stPointer, "jpg?") + 3
iHolderi = iHolderi - iHolder
stNewString = Mid(stPointer, iHolder, iHolderi)
stNewstring2 = "http://pictures.sprintpcs.com" & stNewString
Debug.Print stNewstring2
End With
With objHTTP
.HttpURL = stNewstring2
stststring = "C:\Link\" & Mid(stNewString, 4, 21)
'.DestinationFile = stststring
.PromptWithCommonDialog = True
If .FileExists Then .OverwriteTarget = True
If Not .IsConnected Then .DialDefaultNumber
.ConnectToHTTPHost
.WriteHTTPDataToFile
End With
rs.MoveNext
Loop While Not rs.EOF
Set objFTP = Nothing
Call SysCmd(acSysCmdRemoveMeter)
End Sub
Thanks for the help
Andy
Sub Trim_Text()
On Error Resume Next
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strbody, strJpeg, strJpegEnd, strPhotoaddress, strPhotoString As String
Dim strMsg As String
Dim strslm As String
Dim strfrom As String
Dim oHTTP As [Mail Test].HTTP
Set db = CurrentDb
Set rs = db.OpenRecordset("Query1")
Set objHTTP = New [Mail Test].HTTP
Do
strbody = rs.Fields(0)
strfrom = InStr(1, strbody, "from")
strNumber = Mid(strbody, strfrom + 7, 10)
strJpeg = InStr(1, strbody, "View") + 6
strJpegEnd = InStr(strJpeg, strbody, ">")
strPhotoaddress = (strJpegEnd - strJpeg)
strPhotoString = Mid(strbody, strJpeg, strPhotoaddress)
strPhotoString = Trim(strPhotoString)
strMsg = InStr(1, strbody, "Message:") + 9
strmsg1 = InStr(strMsg, strbody, " ")
strslm = Mid(strbody, strMsg, strmsg1 - strMsg) + 0
strCustomerNumber = InStr(strmsg1 + 1, strbody, " ")
strCustomerNumber = Mid(strbody, strmsg1 + 1, strCustomerNumber - strmsg1)
With objHTTP
.HttpURL = strPhotoString
'.DestinationFile = stName
.PromptWithCommonDialog = False
If .FileExists Then .OverwriteTarget = True
If Not .IsConnected Then .DialDefaultNumber
.ConnectToHTTPHost
stPointer = .WriteHTTPDataToString
iHolder = InStr(1, stPointer, "/i/")
iHolderi = InStr(1, stPointer, "jpg?") + 3
iHolderi = iHolderi - iHolder
stNewString = Mid(stPointer, iHolder, iHolderi)
stNewstring2 = "http://pictures.sprintpcs.com" & stNewString
Debug.Print stNewstring2
End With
With objHTTP
.HttpURL = stNewstring2
stststring = "C:\Link\" & Mid(stNewString, 4, 21)
'.DestinationFile = stststring
.PromptWithCommonDialog = True
If .FileExists Then .OverwriteTarget = True
If Not .IsConnected Then .DialDefaultNumber
.ConnectToHTTPHost
.WriteHTTPDataToFile
End With
rs.MoveNext
Loop While Not rs.EOF
Set objFTP = Nothing
Call SysCmd(acSysCmdRemoveMeter)
End Sub
Thanks for the help
Andy