Monday, 15 September 2014

asp.net - VB.Net Outlook email creation works locally, fails on server -



asp.net - VB.Net Outlook email creation works locally, fails on server -

when run project on local machine generates outlook email expected, if upload code our development server, fails error message when run: [exception: cannot create activex component.] microsoft.visualbasic.interaction.createobject(string progid, string servername) +509721 etc...

i know it's outlook that's failing because if comment sendmail() function, rest of page works fine. (it doesn't create email). local machine windows 7 outlook installed, server 2008r2 no office installed. have other pages can write excel files, they're using crystalreports handle i'm not sure if server needs outlook dll registered, or if else needs happen.

aspx page vb.net codebehind. create email looks like:

dim oapp2 object, omail2 object, signature2 string oapp2 = createobject("outlook.application") omail2 = oapp2.createitem(0) dim alattachlist new arraylist(2) dim icounter integer alattachlist.insert(0, "e:\test\debug code.txt") alattachlist.insert(1, "\\remoteserver\z\test\hello.bmp") sbody += "<br />" + "attached files." + "<br />" + "they can found in: x:\test\test\name " omail2 .display() end signature2 = omail2.htmlbody omail2 .subject = ssubject .to = sto .cc = scc .htmlbody = sbody & "<br /><br />" & signature2 end dim sbodylen integer = int(sbody.length) dim oattachs2 interop.outlook.attachments = omail2.attachments dim oattach2 interop.outlook.attachment icounter = 0 alattachlist.count - 1 oattach2 = oattachs2.add(source:=alattachlist(icounter), displayname:=alattachlist(icounter)) next omail2.display(true) oapp2 = nil omail2 = nil

when like:

oapp2 = createobject("outlook.application")

you using office.interop libraries installed ms office (or individual applications if go route)

you must install ms office, or @ to the lowest degree outlook, on server utilize office.interop. might using mapi instead of interop send emails. mapi part of .net , not require additional programs installed on server.

asp.net vb.net outlook

No comments:

Post a Comment