[Last Call] Learn how to a build a cloud-first strategyRegister Now


How to to add com references manually to aspx page?

Posted on 2005-04-28
Medium Priority
Last Modified: 2012-06-27
How to to add com references manually to the aspx page?  I want to send email using Microsoft outlook from my aspx page, I have used some code as the following:

Dim obj as new Outlook.Application

but I got some compilation error:

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30002: Type 'Outlook.Application' is not defined.

Source Error:
Line 12: Sub btn_Click(sender as Object, e as System.EventArgs)
Line 13:  If  Request.Form("Email") <> "" Then
Line 14:     Dim outObj As New Outlook.Application
Line 15:      Dim Item As Outlook.MailItemClass
Line 16:      

Source File: http://localhost/mailTest.aspx    Line: 14

how to solve this problem?


Question by:kindy
  • 2
LVL 13

Accepted Solution

davidlars99 earned 360 total points
ID: 13894432
for this to work you need make refference with two objects, "Outlook.dll" and "stdole.dll", the reason your program doesn't work, might be "stdole.dll" if you already have "Outlook.dll" properly refferenced and if not then you need them both!

Dim ol As New Outlook.Application()
Dim ns As Outlook.NameSpace
Dim fdMail As Outlook.MAPIFolder

ns = ol.GetNamespace("MAPI")
ns.Logon(, , True, True)  '// ns.Logon(Username, Password, ShowDialog, NewSession

Dim newMail As Outlook.MailItem

fdMail = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox)

newMail = fdMail.Items.Add(Outlook.OlItemType.olMailItem)
newMail.Subject = subjectVal
newMail.Body = bodyVal
newMail.To = toVal
newMail.SaveSentMessageFolder = fdMail
LVL 13

Expert Comment

ID: 13894561
wait, you mean manually without visual studio..? open command prompt window and type in the following

CD C:\Program Files\Microsoft.NET\SDK\v1.x.xxxx\Bin

VBC.exe /t:library  /out:C:\MyProjects\OutputObjectName  /r:System.dll,System.Data.dll,System.Drawing.dll,System.Web.UI.dll,Outlook.dll,stdole.dll  C:\MyProjects\InputObjectName.vb

where "OutputObjectName" is file name afterwards and "InputObjectName.vb" is what it says it is...

Assisted Solution

jaymoFizzle earned 140 total points
ID: 13906986
Do you really need to use outlook or just send an email ?

there is an email object that can send it for you and will not incur any overhead or interacting with outlook each time.

There is a good sample from

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month18 days, 12 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question