|
Hi,
I have some code which uses CDO to retrieve a mail item from outlook
I know that the body is stored in RTF and have read this from CDO.
My problem is that the RTF is in compressed format - now doing some google research I have have found an API call to uncompress the RTF.
I just cant get the code to call the API correctly.
Can you have a look at the code and tell me where I am being dumb please
Public Const MAPI_MODIFY As UInteger = &H1<br />
Public Const STORE_UNCOMPRESSED_RTF As UInteger = &H8000<br />
<br />
Public Declare Function WrapCompressedRTFStream Lib "mapi32.dll" (<MarshalAs(UnmanagedType.Interface)> ByRef lpCompressedRTFStream As IStream, ByVal uFlags As UInt32, <MarshalAs(UnmanagedType.Interface)> ByRef lpUncompressedStream As IStream) As Integer<br />
<br />
Function getRTFfromCDO(ByVal sEntryId As String)<br />
Dim objCDO As MAPI.Session<br />
Dim objMail As MAPI.Message<br />
' Dim strmOut As MemoryStream<br />
Dim lpsource As ADODB.Stream = New ADODB.Stream ' Microsoft ADODB Com object reference<br />
Dim lptarget As ADODB.Stream = New ADODB.Stream<br />
<br />
Const CdoPR_RTF_COMPRESSED = &H10090102<br />
objCDO = CreateObject("MAPI.Session")<br />
objCDO.Logon("", "", False, False)<br />
objMail = objCDO.GetMessage(sEntryId)<br />
Try<br />
lpsource.Type = StreamTypeEnum.adTypeText<br />
lptarget.Type = StreamTypeEnum.adTypeText<br />
lpsource.Open()<br />
lpsource.WriteText(objMail.Fields(CdoPR_RTF_COMPRESSED).Value)<br />
WrapCompressedRTFStream(lpsource, STORE_UNCOMPRESSED_RTF, lptarget)<br />
Catch ex As Exception<br />
MsgBox(ex.Message)<br />
End Try<br />
<br />
'Return objMail.Fields(CdoPR_RTF_COMPRESSED).Value<br />
objCDO.Logoff()<br />
End Function
thanks
Martin
life is a bowl of cherries
go on take a byte
|
|
|
|
|
You've got several problems. The lack of anyone using this API with C# or VB.NET is one of them, so documentation and support is lacking.
First, I think your declaration has to look more like:
Private Declare Auto Function WrapCompressedRTFStream Lib "mapi32.dll" ( _
<MarshalAs(UnmanagedType.Interface)> ByVal lpCompressedRTFStream As ComTypes.IStream, _
ByVal ulFlags As UInt32, _
<MarshalAs(UnmanagedType.Interface)> ByVal lpUncompressedRTFStream As ComTypes.IStream) _
As Integer
I have no way of testing this!
Second. You create an lpSource stream, but you never associate that stream with the incomming data. It's a stream that points to nothing. Some thing with your lpTarget. It also points to God knows what. You haven't told either of these object where the source and destination streams are actually supposed to get/write their data.
' OK...You've created a couple of Streams. What are they looking at?? Nothing!
Dim lpsource As ADODB.Stream = New ADODB.Stream ' Microsoft ADODB Com object reference
Dim lptarget As ADODB.Stream = New ADODB.Stream
...
Try
' Great! You set the stream types, but you still haven't told the source stream
' where to get it's data from!
lpsource.Type = StreamTypeEnum.adTypeText
lptarget.Type = StreamTypeEnum.adTypeText
' Open what stream??
lpsource.Open()
' I have no idea what this line is doing, nor why it's even here.
lpsource.WriteText(objMail.Fields(CdoPR_RTF_COMPRESSED).Value)
WrapCompressedRTFStream(lpsource, STORE_UNCOMPRESSED_RTF, lptarget)
' OK. Now you've got the source stream wrapped. But you don't read anything and
' you don't write anything to any stream. All you did was wrap the source for
' decompression!
??????
From what I've seen in the docs for WrapCompressed... the stream you should be reading to get the uncompressed RTF is the lptarget stream.
I can't tell you exactly how to fix these problems. I have nothing to test any code with that will supply a compressed RTF in an email.
|
|
|
|
|
Hello,
The lpsource stream I am populating with the string defined by
objMail.Fields(CdoPR_RTF_COMPRESSED).Value
which is the compressed RTF stream of the Mail item as extracted by CDO - hence the Open and writeText
Its values in my example is
"C9020000750400004C5A46759FA2E86903000A0072637067313235163200F80B606E0E103033334F01F702A403E3020063680AC073F0657430200713028300501066187072710E5010D85461689B037102807D0A8008C8203B096FED0E3035028014322A09B009F00490D4617405B1520DE068098001D00020352E35302E3939922E01D0303902805C760890A4776B0B8064340C606300503D0B036312020BC50F0201D035370F0AA20A811A2011516E79206F6E7417A005C01730700DE0042079A10860206775790420770070FB05400B80630A4001000B311B831B739B139017A0200AC005406F661D50526F047020620AC062059075F90B80673F20F01E8A1A131B7703C17C31381AD30F4205D01F910B8020CA4B09F0640510636B033000A05122D136284C022064022029030C4022B42020782038361E311B561A9F21670B036C6933DE36014012B01C5005907411F42500FC205F2A6F2B7F2C280AE30A8229740729410B132976692D3134343D27416922F018900CC12F4362205A4603613A03300C9262115043F1036075742C24101C302D3630701B066002303A30F626014A756CCB1C301881373370353A18A0322774546F32F75308902080032053187570700911322875626A8B29A132F74116D164612002107F05C00780113020C11C4003A0309069653890793227496D3682007063C26532F74869676827EC2D
CF1F29A229040BB538451E8A2A2050E3036037822055703890299010B0D33FF50800616400C07033F418819323003FF64D4D3FE641751D60967305400460761F7028410540386C65614451031003206B6EDA6F07E07717A003A04A457245307620097041F02036601CA11CA068ED04002036800B807425903FF523B1F524902D07B34310F00F201F7119505F13900790054029613B2064087065EF1E8A1C1F1D2F1E3320211B31E02317FF212B25E331E1317324B52620252626307E380E404FA025B30C011E99142100015440" {String}
The lptarget stream I assumed was going to be populated by the uncompressed version of the text.
I read somewhere the ADODB.Stream was in effect a derived istream and could be used like that.
Is that true?
with your changes added , the API complained about an unopen lptarget stream
so I added an lptarget.open
now when I run it I get no error number but the lptarget.size is 0
any ideas??
Thanks
Martin
life is a bowl of cherries
go on take a byte
|
|
|
|
|
Hi,
I am trying to take a screen shot of a form without displaying it to the user. Here is the code:
Public Sub TakeScreenShot(ByVal windowHandle As IntPtr)
Dim screenBmp As Bitmap
Dim gfxScreenshot As Graphics
'Set the bitmap object size to the size of the form
screenBmp = New Bitmap((Screen.FromHandle(windowHandle)).Bounds.Width, (Screen.FromHandle(windowHandle)).PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb)
'Create a graphics object from the bitmap
gfxScreenshot = Graphics.FromImage(screenBmp)
'Take the screenshot from the upper left corner to the right bottom corner of the form
gfxScreenshot.CopyFromScreen((Screen.FromHandle(windowHandle)).Bounds.X, (Screen.FromHandle(windowHandle)).Bounds.Y, 0, 0, (Screen.FromHandle(windowHandle)).Bounds.Size, CopyPixelOperation.SourceCopy)
'Save the screen shot
screenBmp.Save("C:\test.jpg", ImageFormat.Jpeg)
End Sub
But what it ends up doing instead is taking a screenshot of the whole screen without the form! How can I fix this?
Thanks in advance!
Ahmad
|
|
|
|
|
Try this:
Dim Pic As Bitmap<br />
Dim SS As Graphics<br />
<br />
Pic = New Bitmap(me.width, me.height, Imaging.PixelFormat.Format32bppArgb)<br />
SS = Graphics.FromImage(Pic)<br />
SS.CopyFromScreen(me.location.x, me.location.Y, 0, 0, me.size, CopyPixelOperation.SourceCopy)<br />
<br />
pic.save("C:\test.jpg", ImageFormat.Jpeg)
|
|
|
|
|
its giving a few probs:
a) If the form is in the background then the screen shot contains an image on the contents of the screen rather then the form. I want to take a shot of the form while having it in the background.
b) Sometimes it just gives a plain white image. Any idea why that would be?
Thanks.
|
|
|
|
|
i am creting exe (package) in vb.net that has crystal reports. do i need to install Crystal Reports in client machine to execute it.??
|
|
|
|
|
You will need to distribute the Crystal Report Merge Modules with your app. You can get them from the BusinessObjects.com website
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
thax
i did it adding prerequisites..... and works...
|
|
|
|
|
hi
is it necessary to install crystal report in the client machine to execute the crystal report
through vb.net exe/package....???
Thanx
Jayesh Talsaniya
|
|
|
|
|
Hi,
runtimes files on the target machine are required, you could distribute the required files by building a setup project (File > Add Project > Setup ...)
Right mouse on the Setup Project in the Solution explorer window > Add > Merge Module... > select Microsoft_VC80_DebugCRT_x86.msm
for more details plz go to http://msdn2.microsoft.com/en-us/library/ms225293(VS.80).aspx[^]
Good Luck ,
NajiCo
It's nice 2b important, but it's more important 2b nice...
|
|
|
|
|
thank you for taking interest in my problem.
if i add Microsoft_VC80_DebugCRT_x86.msm in the package then do i need to install runtime in the client machine..
thanx agian.
|
|
|
|
|
Nope, this Merge Module contains all that is required
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Thank You.
|
|
|
|
|
|
can i know how to save the time a card is scanned using vb.net.
example: a employee scan their id card and the system need to save time the card was scanned and save it in the database.
can it be done?
|
|
|
|
|
Depends, obviously the card reader can detect when a card is scanned. In this case you should be able to have a feild in your database that is set as a datetime and then simply update it with datetime.now when the card is scanned. You can find out how to do that in google.
|
|
|
|
|
|
Hi Friend..
I have one datagrid and in that i have taken one Template Column containing label control. I want to blink the text clot of that label. Can u help me out to do this task?
Gurudatta B. Shelke
|
|
|
|
|
Add a timer to your form and on Tick event add this code
LableName.Visible = Not LableName.Visible
Hope this helps.
Regards.
|
|
|
|
|
I'm currently working on a VB.NET project that requires several different types of items to be dragged on to a listview control (to put it very simply).
E.g. currently I have it running so I can drag a file from windows explorer on to the listview and a new listviewitem is created with the file name as the item text.
The problem I'm now encountering, is that I need to be able to drag treeview nodes from an existing old Visual Basic application (which has several treeviews), on to the listview in the new application. I have the source of the Visual Basic app so that can be modified if need be.
At the moment it's set up (not by me) so that items can be dragged between the various treeviews within the Visual Basic app, but I can't get it to recognise dragging *out* of that application on to the new one.
Any help would be greatly appreciated, let me know if you need more info...
|
|
|
|
|
The treeview may need to have the drag and drop enabled. From there you have to capture the events that fire when drag and drop occurs.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Why does the Child form always appear behind the other controls on the form?
|
|
|
|
|
Because the MDI CHild formis being rendered inside another control on the Parent form, called the MdiClient. Putting controls on the surface of an MDI Parent will always have them show up on top of this MdiClient control.
|
|
|
|
|
Hi,
I've been trying to work out how to iterate through a collection object using reflection.
I have a class with a few simple objects, strings, single[] arrays, and one collection.
However, when I'm using the GetFields() method to retrieve the objects in my class, when it gets to the collection I am unable to view all the items in the collection.
dim coll as collection = FieldInfoObj.getvalue(obj)
console.writeline("Collection has " & coll.count & " items in the collection")
for each item as object in coll
do_stuff(item)
next
Although it correctly states that I have 4 items in the collection, item 1 is Ok. item 2 is 'nothing' and item 3 causes an error. But I do actually have 4 'singles' in the collection.
How do i access the collection objects using reflection?
I *think* I need to reflect into each object seperately, and not just iterate through them after setting the main collection object using the getvalue(obj) method as I would with the other system.xxx type objects (which work fine)
Could anyone provide a simple example of how to iterate through a collection using reflection?
Thanks in advance,
Phil.
|
|
|
|