I try to take a screenshot of an email msg file.
The problem is that the part with the email - body is missing in the screenshot.
Maybe someone has a solution.
Best regards,
Otto
- Code: Select all Expand view RUN
function MSGToJpeg( cMSG )
local cTitle := ""
local hWnd, hBmp, hBmp2, hDib, cBuf, nWait := 2
local lRet := .f.
local nWidth := GetSysMetrics( 0 )
local nHeight := GetSysMetrics( 1 )
local aClass := {}
cTitle := msgGetTitle( cMSG )
if nWidth > 1920
nWidth := 1920
endif
if File( cMSG )
ShellExecute( 0, 'Open', cMSG )
SysWait( 3 )
do while nWait < 5 .and. Empty( hWnd := FindWnd( cTitle ) )
SysWait( nWait )
nWait += 1
enddo
if ! Empty( hWnd )
SetFocus( hWnd )
SetForeGroundWindow( hWnd )
SysRefresh()
SysWait( 0.8 )
// for a test
EnumChildWindows( hWnd,;
{ | hWnd, nLParam | AADD( aClass,{ GetClassName( hWnd ), hWnd } ), .T. },; // .T. means continue
0 ) // optional supplied value
xbrowse( aClass )
// for a test end
hBmp := WndBitmap( hWnd )
SendMessage( hWnd, WM_CLOSE )
hBmp2 := BmpTrim( hBmp )
DeleteObject( hBmp )
// hBmp2 := CropImage( hBmp2, 150, 420, nHeight,nWidth-420 )
hDib := DibFromBitmap( hBmp2 )
cBuf := DibToStr( hDib )
GlobalFree( hDib )
DeleteObject( hBmp2 )
lRet := BmpBufToJpg( cFileSetExt( cMSG, "jpg" ), cBuf )
cBuf := nil
endif
endif
return lRet
//----------------------------------------------------------------------------//
function msgGetTitle( cFile )
LOCAL oOutlook := TOleAuto():New( "Outlook.Application" )
local myOlExp := oOutlook:ActiveExplorer
local oMail
oMail := oOutlook:CreateItemFromTemplate( Alltrim( cFile ) )
return ( oMail:Subject )
//----------------------------------------------------------------------------//