Outlook es de solo lectura. (4096)

Outlook es de solo lectura. (4096)

Postby Garbi » Thu Feb 22, 2018 12:01 pm

Hola, sigo intentando modificar rpreview.prg usando el outlook para mejorar el envio de email y con este codigo me da el siguiente error :

¿Alguna sugerencia? Llevo tiempo intentando varias cosas, pero no consigo que funcione.

El error me aparece cuando activo oMail:Display = .T., si lo quito no aparece el error pero tampoco aparece la ventana del outlook.

Si lo quito y pongo : oMail:Send() envia correctamente el email, solo me falla el Display

Pongo el código más abajo.

Error description: (DOS Error -2147352567) WINOLE/1006 Esta propiedad es de solo lectura. (4096): Microsoft Outlook

Args:
[ 1] = L .T.

Stack Calls
===========
Called from: => TOLEAUTO:_DISPLAY(0)
Called from: .\rpreview.PRG => TPREVIEW:SENDEMAIL(0)
Called from: .\rpreview.PRG => (b)TPREVIEW_BUILDBUTTONBAR(0)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK(638)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP(872)
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(1723)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT(1705)
Called from: .\source\classes\WINDOW.PRG => _FWH(3553)
Called from: => WINRUN(0)
Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE(1020)
Called from: .\crman.PRG => MAIN(0)

Code: Select all  Expand view
METHOD SendEmail() CLASS TPreview

   local oMail, cName, cFile, olMailItem, oOutLook, oAttach

   cName := If( ::oReport != nil, ::oReport:cName, ::oDevice:cDocument )
*   cFile := cFilePath( ::oDevice:aMeta[ 1 ] ) + StrTran( cName, '.', '' ) + ;
*            Left( HB_TToS( HB_DateTime() ), 14 ) + ".pdf"
   cFile := cFilePath( ::oDevice:aMeta[ 1 ] ) + StrTran( cName, '.', '' ) + ".pdf"

   CursorWait()
   cFile := ::SaveAs( .t., cFile, .f. )
   CursorArrow()

   if ! File( cFile )
      MsgInfo( FWString( "PDF not saved to send Email" ), FWString( "Information" ) )
   elseif ::bEmail != nil
      Eval( ::bEmail, Self, cName, cFile )
   else
    TRY
        oOutLook   := GetActiveObject("Outlook.Application")
        EmSend     := .T.
      CATCH
       TRY
          oOutLook   := GetActiveObject("Outlook.Application")
          EmSend     := .F.
      CATCH
         EmSend   := .F.
      END
    END

   IF !EmSend
       ShellExecute(,"Open","Outlook",,,3)
       EmSend = .T.
   ENDIF

   IF EmSend
      oOutlook = CREATEOBJECT( "Outlook.Application" )
      oNameSpace := oOutlook:GetNameSpace("MAPI")
      oMail = oOutlook:CreateItem( olMailItem )
      oMail:to := vmailpre
      oMail:Subject = cName
      oMail:htmlBody =" "
      oMail:BodyFormat := 2          // FORMAT HTML
      oMail:Display = .T.
   endif

   endif

   ::oMeta1:SetFocus()

return nil
 
Saludos,
Regards,

Jose Luis Alepuz
joseluis@mancomputer.com
www.mancomputer.com
Garbi
 
Posts: 289
Joined: Wed Nov 02, 2005 3:28 pm


Re: Outlook es de solo lectura. (4096)

Postby Garbi » Thu Feb 22, 2018 12:57 pm

Funcionando Perfectamente.

Solo cambiar oMail:Display = .T. por oMail:Display(.T.)

Muchas Gracias
Saludos,
Regards,

Jose Luis Alepuz
joseluis@mancomputer.com
www.mancomputer.com
Garbi
 
Posts: 289
Joined: Wed Nov 02, 2005 3:28 pm


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 10 guests