Solved

Using CDO to access an Exchange 5.5 Server

Posted on 2004-04-14
4
150 Views
Last Modified: 2013-12-24
I found this code, which supposedly allows you to read inbox messages, at CFComet:

http://www.cfcomet.com/Outlook/index.cfm?ArticleID=54E12396-5696-11D3-B3E8004033E03EF9

But when I run it, I get this error:

An exception occurred when instantiating a Com object.  
The cause of this exception was that: coldfusion.runtime.com.ComObjectInstantiationException: An exception occurred when instantiating a Com object..  
 
The error occurred in X:\Dir\test3.cfm: line 21
Called from X:\Dir\test3.cfm: line 21
Called from X:\Dir\test3.cfm: line 21
 
19 :     <CFOBJECT
20 :         ACTION="CREATE"
21 :         CLASS="Outlook.Application"
22 :         NAME="objOutlook"
23 :         TYPE="COM">

0
Comment
Question by:fairoakian
  • 2
  • 2
4 Comments
 
LVL 18

Expert Comment

by:Plucka
Comment Utility
Hi fairoakian,

You need to have outlook installed on the server, do you have this.
0
 

Author Comment

by:fairoakian
Comment Utility
I do now, thanks.  But the page just keeps loading and never loads.

<!--- Get the object --->
<CFTRY>
    <!--- If it exists, connect to it --->
    <CFOBJECT
        ACTION="CONNECT"
        CLASS="Outlook.Application"
        NAME="objOutlook"
        TYPE="COM">
  <CFCATCH>
    <!--- The object doesn't exist, so create it --->
    <CFOBJECT
        ACTION="CREATE"
        CLASS="Outlook.Application"
        NAME="objOutlook"
        TYPE="COM">
  </CFCATCH>
</CFTRY>

<CFSCRIPT>
    /* Get the object name space - currently MAPI is the only option */
     objNameSpace = objOutlook.getNameSpace("MAPI");

    /* If you're on Windows NT or 2000, use the next line */
     objNameSpace.Logon("user", "pwd", False, False);

    /* Set the folder to Inbox which is '6' */
     objFolder = objNameSpace.getDefaultFolder(6);

    /* Return the 'Items' collection */
     objAllMessages = objFolder.Items;
   
    /* Sort the messages by date descending */  
     objAllMessages.Sort("[ReceivedTime]", 1);
</CFSCRIPT>

<CFOUTPUT>
You have a total of #objAllMessages.Count# messages, #objFolder.UnreadItemCount# are unread:<P>

<TABLE CELLPADDING="2" CELLSPACING="1" BORDER="0" WIDTH="100%" BGCOLOR="gray">
    <TR BGCOLOR="ffffff">
        <TD><B>Sender</B></TD>
        <TD><B>Date</B></TD>
        <TD><B>Size</B></TD>
        <TD><B>Subject</B></TD>
    </TR>
<!--- Loop through the 'Messages' collection --->
<CFLOOP COLLECTION="#objAllMessages#" ITEM="this">
    <TR BGCOLOR="ffffff">
        <TD>#this.SenderName#</TD>
        <TD>#DateFormat(this.ReceivedTime, "ddd mm/dd")#</TD>
        <TD>#iif(this.size LT 1000, DE("#this.size#b"), DE("#Round(this.Size/1000)#k"))#</TD>
        <TD><A HREF="ViewMessage.cfm?entryID=#this.EntryID#">
            #iif(this.UnRead, DE("<B>#this.Subject#</B>"), DE("#this.Subject#"))#
            </A>
        </TD>
    </TR>
</CFLOOP>
</TABLE>
</CFOUTPUT>
0
 
LVL 18

Accepted Solution

by:
Plucka earned 500 total points
Comment Utility
fairoakian,

It's probably waiting for something, the mailbox would also have to be on the server. Best to go to the server console and run the page, you may see outlook spawn and give you some idea of why it's not finishing.

Regards
Plucka
0
 

Author Comment

by:fairoakian
Comment Utility
Hmm...then this probably won't work for me.  I was hoping to use this for 30+ employees, but that doesn't appear plausible.  Thanks.
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now