c# - Unable to open mailItem because of outlook interface..! -
i have application create mailitem using outlook interop. on systems code works without problems.
but on 1 of systems error appears:
message= unable cast com object of type 'microsoft.office.interop.outlook.applicationclass' interface type 'microsoft.office.interop.outlook._application'. operation failed because queryinterface call on com component interface iid '{00063001-0000-0000-c000-000000000046}' failed
due following error: interface not registered
i think has register see: answer on error accesing com components
but need solve problem in code, because can't acces systems kind of problem.
using outlook = microsoft.office.interop.outlook; //create email body customers string mailbody = customers; //create email settings outlook.application outlookapp = new outlook.application(); outlook.mailitem mailitem = (outlook.mailitem)outlookapp.createitem(outlook.olitemtype.olmailitem); mailitem.subject = mailsubject; mailitem.attachments.add(totalpath); mailitem.body = mailbody; mailitem.importance = outlook.olimportance.olimportancenormal; try { //try open outlook, set message if not possible open outlook mailitem.display(true); } catch (exception ex) { messagebox.show(ex.message); return false; } how can solve in code?
p.s. every system uses office 2013 version!
try use following code instead:
oapp = activator.createinstance(type.gettypefromprogid("outlook.application")) microsoft.office.interop.outlook.application; it looks wrong windows registry records. take @ similar forum thread - error: unable cast com object of type 'microsoft.office.interop.outlook.applicationclass' interface type 'microsoft.office.interop.outlook._application'..
do have click2run edition of office installed on pc? see how to: verify whether outlook click-to-run application on computer more information.
Comments
Post a Comment