I converted a funtion from VBScript to VFP
Only a line in the final of the fuction returns error message:
Stream.CharSet = CharSet
OLE IDispatch exception code 0 FROM ADODB
Below are the funcion I created and also the original funtion in the button
I'd be glad if someone could take a look
************ This is the function I created*************************************
Function QuotedPrintableDecode(SourceData, CharSet)
*Create CDO.Message object For the encoding.
Message = CreateObject("CDO.Message")
*Set the encoding
Message.BodyPart.ContentTransferEncoding = "quoted-printable"
*Get the data stream To write source string data
*public Stream &&As ADODB.Stream
Stream = Message.BodyPart.GetEncodedContentStream
If VarType(SourceData) = "C" && vbString
*Write the VBScript string To the stream.
Stream.WriteText = SourceData
Else
*'Set the type of the stream To adTypeBinary.
Stream.Type = 1
*Write the source binary data To the stream.
Stream.Write = SourceData
EndIf
*Store the data To the message BodyPart
Stream.Flush
*Get an encoded stream
Stream = Message.BodyPart.GetDecodedContentStream
*Set the type of the stream To adTypeBinary.
Stream.CharSet = CharSet &&& this line returns error
*You can use Read method To get a binary data.
QuotedPrintableDecode = Stream.ReadText
End Function
*****************************Original funcion*******************************************
'VBScript QuotedPrintableDecode decoding Function
'2005 Antonin Foller
http://www.motobit.comFunction QuotedPrintableDecode(SourceData, CharSet)
'Create CDO.Message object For the encoding.
Dim Message: Set Message = CreateObject("CDO.Message")
'Set the encoding
Message.BodyPart.ContentTransferEncoding = "quoted-printable"
'Get the data stream To write source string data
Dim Stream 'As ADODB.Stream
Set Stream = Message.BodyPart.GetEncodedContentStream
If VarType(SourceData) = vbString Then
'Write the VBScript string To the stream.
Stream.WriteText SourceData
Else
'Set the type of the stream To adTypeBinary.
Stream.Type = 1
'Write the source binary data To the stream.
Stream.Write SourceData
End If
'Store the data To the message BodyPart
Stream.Flush
'Get an encoded stream
Set Stream = Message.BodyPart.GetDecodedContentStream
'Set the type of the stream To adTypeBinary.
Stream.CharSet = CharSet
'You can use Read method To get a binary data.
QuotedPrintableDecode = Stream.ReadText
End Function