2011-08-04 14 views
10

Cuando me declaro,de Outlook interoperabilidad

Microsoft.Office.Interop.Excel.ApplicationClass excel = 
     new Microsoft.Office.Interop.Excel.ApplicationClass(); 

recibo errores como

'Microsoft.Office.Interop.Outlook.ApplicationClass' no puede ser incrustado. Use la interfaz aplicable en su lugar.

y

El tipo 'Microsoft.Office.Interop.Outlook.ApplicationClass' tiene constructores definidos

¿Cuál es la solución?

+2

Usted está utilizando Excel en su pregunta ... no outlook. –

Respuesta

17

utilizar la interfaz:

Microsoft.Office.Interop.Outlook.Application outlook = new Microsoft.Office.Interop.Outlook.Application() 

o desactivar la inserción de tipos de interoperabilidad para este montaje (Referencias -> Microsoft.Office.Interop.Outlook (clic derecho) -> Propiedades -> Set 'Tipos Insertar Interop' es false)

Más información sobre la razón por la se puede encontrar aquí: http://blogs.msdn.com/b/mshneer/archive/2009/12/07/interop-type-xxx-cannot-be-embedded-use-the-applicable-interface-instead.aspx.

+0

muchas gracias por ayuda – Transistor

2

Utilice esta:

var outlook = new Microsoft.Office.Interop.Outlook.Application();