.net - How to automate Outlook? -
i'm trying send e-mail our erp system. tried using smtp works internal mail , fails external mail complaining unable relay or something. think manager either doesn't want or know how configure exchange properly.
so boss told me use outlook. problem code works fine in debug fails if outlook open, in every case. did work modifying vendors installation, prefer not that. using intuitive erp 8.5. stores library files in standard folder , there custom folder custom code or inherited vendor objects.
program files\intuitiveerp.exe program files\intuitiveerp\custom program files\intuitiveerp\standard
if put program directory on root of c: , combine standard , custom folders code works whether outlook open or closed. prefer not modify vendor's installation because if may cause problems updates.
'fails cannot create activex component. objoutlook = ctype(createobject("outlook.application"), outlook.application) 'fails retrieving com class factory component clsid {0006f03a-0000-0000-c000-000000000046} failed due following error: 80080005. objoutlook = new outlook.application mobjemail = ctype(objoutlook.createitem(outlook.olitemtype.olmailitem), outlook.mailitem) mobjemail .cc = stremployeeemail .subject = string.format(constants.rfq.email.subject, strrfqid) .to = strto .body = constants.rfq.email.body .attachments.add(string.format(constants.rfq.output.fullpath, strrfqid)) .display(true) end
any idea how reference outlook when open? alternative solutions?
you can try this:
try objoutlook = marshal.getactiveobject("outlook.application") catch ex exception objoutlook = ctype(createobject("outlook.application"), outlook.application) end try
note there issues when running inside visual studio administrator , accessing outlook when running in user mode. see this. try running exe directly bin folder (don't run administrator).
Comments
Post a Comment