Friday, March 16, 2012

Please help mee...

Hi,

I am trying access my exchange server thru asp.net. i am using following code. its throwing following error.
----------------------------
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Exception: Cannot create ActiveX component.

Source Error:
Line 22: ' Create the CDO session object
Line 23: objSession = CreateObject("MAPI.Session")
Line 24: bstrProfileInfo = bstrServer + vbLf + strAlias
Line 25: 'Logon

Source File: c:\inetpub\wwwroot\test\exch.aspx Line: 23
----------------------------

what should i do to create it ?? iam totally new to this...please advice me...

Thanks,

Susan

Below is the code iam using ....
----------------------------
<%@dotnet.itags.org. IMPORT NameSpace="System.Web.Mail" %>
<html>
<head>
<script runat="server">
Sub Button_Click(sender As Object, e As EventArgs)
'Put user code to initialize the page here
Dim bstrServer As String
Dim strAlias As String
Dim objSession As Object
Dim bstrProfileInfo As String
Dim objInfoStore As Object
Dim RtFolder As Object
Dim objFolders As Object
Dim ObjFolder As Object
Dim subfolders As Object
Dim Nameval As String
Dim SubFolder As Object

bstrServer = "exchangename" 'the name of the Exchange 5.5 server.
strAlias = "susan voyce"

' Create the CDO session object
objSession = CreateObject("MAPI.Session")
bstrProfileInfo = bstrServer + vbLf + strAlias
'Logon
objSession.Logon(, , , True, , True, bstrProfileInfo)

' Get your default information store
objInfoStore = objSession.GetInfoStore("")
' Get to the root folder
RtFolder = objInfoStore.RootFolder
' Loop through all the folders.
objFolders = RtFolder.Folders
ObjFolder = objFolders.GetFirst()
For Each ObjFolder In objFolders
Nameval = ObjFolder.Name

subfolders = ObjFolder.Folders
If subfolders.Count > 0 Then
SubFolder = subfolders.GetFirst()
For Each SubFolder In subfolders
Nameval = SubFolder.Name

Response.Write("Folder: " & Nameval & "<BR>")

Next
End If
Next
'Logoff and release all the objects
objSession.Logoff()
objSession = Nothing
end sub

</script>
<table width="100%" border="0" cellspacing="1" cellpadding="3"
<tr bgcolor="#F3F3F3">
<td width="200" align="right"><font face="Arial,Helvetica,Geneva" size="2" style="font-size: 11px;">click me?</td
<form runat="server" ID="Form1">
<tr>
<td colspan="2" align="center">
<asp:Button id="Button1"
Text="Send "
OnClick="Button_Click"
runat="server"/>
</td>
</tr>
</form>
</body>
</html>
----------------------------Susan,

Have you attempted to use the MailMessage Class?


Dim myMessage As New Mail.MailMessage()
myMessage.To = myRecip
myMessage.From = myEmailAccount
myMessage.Body = myMessageText
myMessage.BodyFormat = Mail.MailFormat.Text
myMessage.Subject = "Check This Out!"
Mail.SmtpMail.Send(myMessage)

Will this work in your situation?
you cant do it that way in asp.net (that asp only). you need to import the namespace of the object and in most cases create an instance of it. i think that is what you are trying to do.
Oops, left out this piece:
Mail.SmtpMail.SmtpServer = "mySMTPServerName"

:-D
Hi,

CGGamer how to create an instance of it ...and how to import the namespace. please advice me...

netprofit i want to access the public folder of my outlook thru asp.net...

thanks,

susan
the .net framework is made up of classes and namespaces:

http://samples.gotdotnet.com/quickstart/aspplus/samples/classbrowser/vb/classbrowser.aspx

you can import a namespace such as:

<%@. Import Namespace="System.Data" %
and create an instance of an object from that namespace like:

dim objDR as new DataRow

what you are looking for is the System.IO Namespace. it allows you search through files on your computer and other things too. take a look at it in the link above.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemIOPathClassTopic.asp

i will try to find examples and post there links.
http://dotnetjunkies.com/tutorials.aspx?tutorialid=392

http://www.aspfree.com/aspnet/filedirhandling.aspx

http://www.vbwm.com/articles/builder/viewer.asp?ArticleID=15

hope these help
i know createobject creates an instance . but the line which tries create an instance is throwing error . "CANNOT CREATE ACTIVEX COMPONENT".

any idea ...??

Thanks !
Susan, this usually happens if the DLL is missing from the machine, or if it is on the machine but not registered.
Netprofit,

yes ..that was the problem...cdosys.dll is not registered in my XP machine. when i try to register

REGSVR32 "C:WINDOWS\SYSTEM32\CDOSYS.DLL"

with quotes and without quoter tried. still , i am getting following error.

DLLREGISTERSERVER IN CDOSYS.DLL FAILED. RETURN CODE WAS: 0x800704da

please advice me...

Thanks !

Susan
try navigating to the directory the dll is in and run the register command without quotes -
bclick,

i opened dos screen and navigate to the directory where cdosys.dll exists and tried REGSVR32 cdosys.dll.

but same error ...(:

help me , please...
Susan, install/reinstall Office 2000.
netprofit,

even though ,reinstalling OFFICE 2000 is tough for me, i want to ask u , is there anything particular i have to look , so that registering of CDOSYS works fine.

i tried in my Windows 2000 machine. and tried to register same. but it is also throwing same error.

but why its throwing that error ..

any one got any suggestion ...

Thanks !

0 comments:

Post a Comment