File UPload->Request.binaryREAD.. -> ADODB.Stream, ->Attach as a CDO Msg ??? 
Author Message
 File UPload->Request.binaryREAD.. -> ADODB.Stream, ->Attach as a CDO Msg ???

Hi All
How to you write binary data parsed from a request.Binaryread into
an adodb.stream object ???,
once I have got that I can stuff the stream into the cdo body part.

Right now I am able to parse the
BinData = request.BinaryRead(request.TotalBytes) into the name/value pairs
sent from the client, that binary data is extracted using midB like this
   Value = MidB(BinData,Start,End-Start)

I know I am doing this right because I can
response.ContentType = "application/octet-stream
response.binaryWrite(value)
& the doc or gif or jpg comes back OK

OR
I am able to save it to the file system using
dim fso, debugfile
Set fso = CreateObject("Scripting.FileSystemObject")
Set debugfile = fso.CreateTextFile("e:\tmp\test.doc")
For i = 1 to LenB(value)
  debugfile.Write chr(AscB(MidB(value,i,1)))
Next

Then I try writing to a adodb.stream
dim oStream
set oStream = server.CreateObject("ADODB.Stream")

oStream.Type = 1 'binary
oStream.open
oStream.write value
oStream.saveTofile "E:\tmp\test.bin"

But it dies as soon as I try to write to the stream ???
ADODB.Stream error '800a0bb9'
Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another.
/log/test.asp, line 49

BUT this works but it is no longer binary ????
 For i= 1 to LenB(Value)
 getStr = getStr & chr(AscB(MidB(Value,i,1)))
 Next
 oStream.WriteText getStr

the next step is
dim oCDOMsg
oCDOMsg = server.CreateObject("CDO.Message")
With oCDOMsg
    Set oBodyPart = .BodyPart.AddBodyPart
    Set oFlds = .Fields
    oBodyPart.ContentMediaType = contenType '"text/html"
    '.ContentTransferEncoding = "base64"
    Set oFlds = oBodyPart.Fields
    oFlds("urn:schemas:mailheader:content-disposition") = "attachment;
filename=""" & FileName & """"
    oFlds.Update
    Set oStream = oBodyPart.GetDecodedContentStream
    oStream.Type = 1 '1-Binary
     oStream.Write Attachment
    'oStream.Flush

End WITH



Mon, 14 Apr 2003 22:17:02 GMT  
 File UPload->Request.binaryREAD.. -> ADODB.Stream, ->Attach as a CDO Msg ???

Just use the original BinData

BinData = request.BinaryRead(request.TotalBytes)
...
.. other stuff ..
.
oStream.Type = 1 'binary
oStream.open
oStream.write BinData
oStream.saveTofile "E:\tmp\test.bin"
.
.. more stuff ..
...

You could create your "debugfile" the same way - no need for all that ugly Chr(AscB(MidB(... stuff.

--
Michael Harris
Microsoft.MVP.Scripting
--

Quote:

> Hi All
> How to you write binary data parsed from a request.Binaryread into
> an adodb.stream object ???,
> once I have got that I can stuff the stream into the cdo body part.

> Right now I am able to parse the
> BinData = request.BinaryRead(request.TotalBytes) into the name/value pairs
> sent from the client, that binary data is extracted using midB like this
>    Value = MidB(BinData,Start,End-Start)

> I know I am doing this right because I can
> response.ContentType = "application/octet-stream
> response.binaryWrite(value)
> & the doc or gif or jpg comes back OK

> OR
> I am able to save it to the file system using
> dim fso, debugfile
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set debugfile = fso.CreateTextFile("e:\tmp\test.doc")
> For i = 1 to LenB(value)
>   debugfile.Write chr(AscB(MidB(value,i,1)))
> Next

> Then I try writing to a adodb.stream
> dim oStream
> set oStream = server.CreateObject("ADODB.Stream")

> oStream.Type = 1 'binary
> oStream.open
> oStream.write value
> oStream.saveTofile "E:\tmp\test.bin"

> But it dies as soon as I try to write to the stream ???
> ADODB.Stream error '800a0bb9'
> Arguments are of the wrong type, are out of acceptable range, or are in
> conflict with one another.
> /log/test.asp, line 49

> BUT this works but it is no longer binary ????
>  For i= 1 to LenB(Value)
>  getStr = getStr & chr(AscB(MidB(Value,i,1)))
>  Next
>  oStream.WriteText getStr

> the next step is
> dim oCDOMsg
> oCDOMsg = server.CreateObject("CDO.Message")
> With oCDOMsg
>     Set oBodyPart = .BodyPart.AddBodyPart
>     Set oFlds = .Fields
>     oBodyPart.ContentMediaType = contenType '"text/html"
>     '.ContentTransferEncoding = "base64"
>     Set oFlds = oBodyPart.Fields
>     oFlds("urn:schemas:mailheader:content-disposition") = "attachment;
> filename=""" & FileName & """"
>     oFlds.Update
>     Set oStream = oBodyPart.GetDecodedContentStream
>     oStream.Type = 1 '1-Binary
>      oStream.Write Attachment
>     'oStream.Flush

> End WITH



Tue, 15 Apr 2003 08:14:40 GMT  
 File UPload->Request.binaryREAD.. -> ADODB.Stream, ->Attach as a CDO Msg ???
But What I want is just the File Attachment that is extracted by the
following stmt
Value = MidB(BinData,Start,End-Start)
This gives me the error
ADODB.Stream error '800a0bb9'
Arguments are of the wrong type, are out of acceptable range, ..

when I do oStream.write Value
but If I convert the value to unicode string I can use oStream.writeText
w/o a problem. SO the issue is what special binary format does
the stream.write want ??? I tried a chrB(0) to the end same errors

ps. The ugly Chr(AscB(MidB(... stuff. was just used to show that the
Value = MidB(BinData,Start,End-Start) was grabbing the correct binary
segment from the request object, that represented the file attachment ..
I know that value is correct because I can write it out & see the attachment
in all its glory on disk server side...

Quote:

>Just use the original BinData

>BinData = request.BinaryRead(request.TotalBytes)
>...
>.. other stuff ..
>.
>oStream.Type = 1 'binary
>oStream.open
>oStream.write BinData
>oStream.saveTofile "E:\tmp\test.bin"
>.
>.. more stuff ..
>...

>You could create your "debugfile" the same way - no need for all that ugly

Chr(AscB(MidB(... stuff.
Quote:

>--
>Michael Harris
>Microsoft.MVP.Scripting
>--



- Show quoted text -

Quote:
>> Hi All
>> How to you write binary data parsed from a request.Binaryread into
>> an adodb.stream object ???,
>> once I have got that I can stuff the stream into the cdo body part.

>> Right now I am able to parse the
>> BinData = request.BinaryRead(request.TotalBytes) into the name/value
pairs
>> sent from the client, that binary data is extracted using midB like this
>>    Value = MidB(BinData,Start,End-Start)

>> I know I am doing this right because I can
>> response.ContentType = "application/octet-stream
>> response.binaryWrite(value)
>> & the doc or gif or jpg comes back OK

>> OR
>> I am able to save it to the file system using
>> dim fso, debugfile
>> Set fso = CreateObject("Scripting.FileSystemObject")
>> Set debugfile = fso.CreateTextFile("e:\tmp\test.doc")
>> For i = 1 to LenB(value)
>>   debugfile.Write chr(AscB(MidB(value,i,1)))
>> Next

>> Then I try writing to a adodb.stream
>> dim oStream
>> set oStream = server.CreateObject("ADODB.Stream")

>> oStream.Type = 1 'binary
>> oStream.open
>> oStream.write value
>> oStream.saveTofile "E:\tmp\test.bin"

>> But it dies as soon as I try to write to the stream ???
>> ADODB.Stream error '800a0bb9'
>> Arguments are of the wrong type, are out of acceptable range, or are in
>> conflict with one another.
>> /log/test.asp, line 49

>> BUT this works but it is no longer binary ????
>>  For i= 1 to LenB(Value)
>>  getStr = getStr & chr(AscB(MidB(Value,i,1)))
>>  Next
>>  oStream.WriteText getStr

>> the next step is
>> dim oCDOMsg
>> oCDOMsg = server.CreateObject("CDO.Message")
>> With oCDOMsg
>>     Set oBodyPart = .BodyPart.AddBodyPart
>>     Set oFlds = .Fields
>>     oBodyPart.ContentMediaType = contenType '"text/html"
>>     '.ContentTransferEncoding = "base64"
>>     Set oFlds = oBodyPart.Fields
>>     oFlds("urn:schemas:mailheader:content-disposition") = "attachment;
>> filename=""" & FileName & """"
>>     oFlds.Update
>>     Set oStream = oBodyPart.GetDecodedContentStream
>>     oStream.Type = 1 '1-Binary
>>      oStream.Write Attachment
>>     'oStream.Flush

>> End WITH



Wed, 16 Apr 2003 02:33:21 GMT  
 File UPload->Request.binaryREAD.. -> ADODB.Stream, ->Attach as a CDO Msg ???

Since you're only posting snippets of code, I don't have a clear picture of *exactly* what you need,
but maybe something like this...

Use 2 Stream objects, say StreamAll and StreamOut both Type Binary.

StreamAll.Mode = 3  'adModeReadWrite
StreamOut.Mode = 2  'adModeWrite

...Open both.

BinData = request.BinaryRead(request.TotalBytes)

...other stuff involving BinData (I assume ;-)
...which includes determining StartPos and EndPos

StreamAll.Write BinData
StreamAll.Position = StartPos
StreamOut.Write StreamAll.Read(EndPos-StartPos)
StreamOut.SaveToFile "E:\tmp\test.bin"
...
...other CDO stuff
...
--
Michael Harris
Microsoft.MVP.Scripting
--

Quote:

> But What I want is just the File Attachment that is extracted by the
> following stmt
> Value = MidB(BinData,Start,End-Start)
> This gives me the error
> ADODB.Stream error '800a0bb9'
> Arguments are of the wrong type, are out of acceptable range, ..

> when I do oStream.write Value
> but If I convert the value to unicode string I can use oStream.writeText
> w/o a problem. SO the issue is what special binary format does
> the stream.write want ??? I tried a chrB(0) to the end same errors

> ps. The ugly Chr(AscB(MidB(... stuff. was just used to show that the
> Value = MidB(BinData,Start,End-Start) was grabbing the correct binary
> segment from the request object, that represented the file attachment ..
> I know that value is correct because I can write it out & see the attachment
> in all its glory on disk server side...


> >Just use the original BinData

> >BinData = request.BinaryRead(request.TotalBytes)
> >...
> >.. other stuff ..
> >.
> >oStream.Type = 1 'binary
> >oStream.open
> >oStream.write BinData
> >oStream.saveTofile "E:\tmp\test.bin"
> >.
> >.. more stuff ..
> >...

> >You could create your "debugfile" the same way - no need for all that ugly
> Chr(AscB(MidB(... stuff.

> >--
> >Michael Harris
> >Microsoft.MVP.Scripting
> >--


> >> Hi All
> >> How to you write binary data parsed from a request.Binaryread into
> >> an adodb.stream object ???,
> >> once I have got that I can stuff the stream into the cdo body part.

> >> Right now I am able to parse the
> >> BinData = request.BinaryRead(request.TotalBytes) into the name/value
> pairs
> >> sent from the client, that binary data is extracted using midB like this
> >>    Value = MidB(BinData,Start,End-Start)

> >> I know I am doing this right because I can
> >> response.ContentType = "application/octet-stream
> >> response.binaryWrite(value)
> >> & the doc or gif or jpg comes back OK

> >> OR
> >> I am able to save it to the file system using
> >> dim fso, debugfile
> >> Set fso = CreateObject("Scripting.FileSystemObject")
> >> Set debugfile = fso.CreateTextFile("e:\tmp\test.doc")
> >> For i = 1 to LenB(value)
> >>   debugfile.Write chr(AscB(MidB(value,i,1)))
> >> Next

> >> Then I try writing to a adodb.stream
> >> dim oStream
> >> set oStream = server.CreateObject("ADODB.Stream")

> >> oStream.Type = 1 'binary
> >> oStream.open
> >> oStream.write value
> >> oStream.saveTofile "E:\tmp\test.bin"

> >> But it dies as soon as I try to write to the stream ???
> >> ADODB.Stream error '800a0bb9'
> >> Arguments are of the wrong type, are out of acceptable range, or are in
> >> conflict with one another.
> >> /log/test.asp, line 49

> >> BUT this works but it is no longer binary ????
> >>  For i= 1 to LenB(Value)
> >>  getStr = getStr & chr(AscB(MidB(Value,i,1)))
> >>  Next
> >>  oStream.WriteText getStr

> >> the next step is
> >> dim oCDOMsg
> >> oCDOMsg = server.CreateObject("CDO.Message")
> >> With oCDOMsg
> >>     Set oBodyPart = .BodyPart.AddBodyPart
> >>     Set oFlds = .Fields
> >>     oBodyPart.ContentMediaType = contenType '"text/html"
> >>     '.ContentTransferEncoding = "base64"
> >>     Set oFlds = oBodyPart.Fields
> >>     oFlds("urn:schemas:mailheader:content-disposition") = "attachment;
> >> filename=""" & FileName & """"
> >>     oFlds.Update
> >>     Set oStream = oBodyPart.GetDecodedContentStream
> >>     oStream.Type = 1 '1-Binary
> >>      oStream.Write Attachment
> >>     'oStream.Flush

> >> End WITH



Wed, 16 Apr 2003 05:28:44 GMT  
 File UPload->Request.binaryREAD.. -> ADODB.Stream, ->Attach as a CDO Msg ???
Thanks for pointing me in the right direction

StreamAll.Write BinData
StreamAll.Position = StartPos-1
StreamOut.Write StreamAll.Read(EndPos-StartPos)
StreamOut.Flush 'gotta flush or else the save get out of context error
StreamOut.SaveToFile "E:\tmp\test.bin"

and the Last part of the story is
set oCDOMsg = server.CreateObject("CDO.Message")
With oCDOMsg
'set Emailto, Emailfrom ...
     Set oBodyPart = .BodyPart.AddBodyPart
     Set oFlds = oBodyPart.Fields
     oFlds("urn:schemas:mailheader:content-disposition") = "attachment;
    filename=""" & FileName & """"
    oFlds.Update
    Set oStream = oBodyPart.GetEncodedContentStream
    oStream.Type = 1 '1-Binary, 2-Text
    oStreamAll.CopyTo oStream
    oStream.Flush
End WITH



Fri, 18 Apr 2003 08:16:27 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. using The Shell Command >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

2. <<<<<<<<ComboBox>>>>>>>>>>>>

3. >>>>>>While Not rst.EOF

4. PSUDOCODE HELP >>>>>>>>>>>

5. >>>> HELP WITH RUNTIME FILES

6. >>>>> Serial Communications

7. VB5 >>>>> Academic Version

8. <<<<HELP- OLE container Control>>>>>>>>>

9. !!! URGENT HELP REQUIRED !!!>>>>>>>>

10. >>= bitwise operations >>

11. Please Help --------->>>>AppLink Problem

12. VB3 ->->->->VBDOS??

 

 
Powered by phpBB® Forum Software