473,386 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

[REPOST] Using CDO from C#

Hi all,

I'm reposting this, as I feel that it may have got buried. If anyone can
help me then I'd really appreciate it...

I am trying to read information from the GAL using C#. I am able to return a
list of all the addresses and names, however, when I walk through each
address I cannot access the mailbox (I keep getting prompted for
authentication information). Given that the long-term goal here is that the
application run unattended as a service this is obviously not desirable...

My environment consists of the following:
CDO 1.21
Exchange 2003
Outlook 2003
VS .NET 2003

The application (which uses CDO by the way) first of all goes to the
Exchange server and builds up a string array of all the users in the GAL.
Having got these addresses it then attempts to login to each individual
mailbox and extract the email addresses in the Contacts folder individual
mailbox which it writes out to a text file.

If you're thinking that this all sounds a bit nefarious then I wouldn't
blame you but let me assure that it isn't. The generated text file is one of
the criteria that the incoming mail filter uses to decide whether a mail
message should be rejected or left through - simple as that.

I chose CDO for two reasons, one was that I wanted to provide some
independence from different Outlook versions and secondly I wanted to bypass
the annoying dialogs that have become a "feature" of Outlook in recent
versions. However I am experiencing some issues which I am hoping that
someone may be able to help me with...

1. The Outlook security dialog is still coming up! This was one of the
reasons behind not using Outlook day one and instead using CDO. The line
that causes the dialog to come up is:

aeAddressEntry = (MAPI.AddressEntry)aesAdressEntries.get_Item(i);

where:
aeAddressEntry is a MAPI.AddressEntry
aesAdressEntries is a MAPI.AddressEntries collection
i is merely a loop counter

2. I am being prompted for a login for each mailbox, despite the fact that
the ID that the process is running under has Admin privileges - why is this?
I try to type acceptable credentials into it but the dialog keeps coming up
again. WhenI eventually cancel it the error that comes back is
MAPI_E_FAILONEPROVIDER.

3. According to the MSKB (cannot remember the KB#) use of CDO through C# is
not supported - if this is indeed the case what am I better off using?

Any help and pointers welcome - much thanks!

ATB,
Derek

"It's all fun and games till someone loses an eye..."
Derek Noonan, Technical Director, ntech.ie
Nov 16 '05 #1
4 5220
Derek,

1. You aren't going to get around the outlook security dialog. It's put
there to indicate to the user that someone is trying to access the mailbox
without them knowing. I can't say I am too fond of this, but I can
understand the reason. You ^might^ be able to get around this by setting up
the exchange server to accept it. Check out the knowledge base article
263297, titled "Administrator information about the Outlook E-mail Security
update: June 7, 2000" located at (watch for line wrap):

http://support.microsoft.com/default...b;EN-US;263297

2. Can you show the code you are using to log in? Even though you have
admin privledges, you might not be indicating correctly who you want to log
in as.

3. I don't see why you couldn't use it. Can you show the knowledge base
article?

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Noonan, Derek" <derek_noonan_at_hotmail_dot_com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi all,

I'm reposting this, as I feel that it may have got buried. If anyone can
help me then I'd really appreciate it...

I am trying to read information from the GAL using C#. I am able to return
a
list of all the addresses and names, however, when I walk through each
address I cannot access the mailbox (I keep getting prompted for
authentication information). Given that the long-term goal here is that
the
application run unattended as a service this is obviously not desirable...

My environment consists of the following:
CDO 1.21
Exchange 2003
Outlook 2003
VS .NET 2003

The application (which uses CDO by the way) first of all goes to the
Exchange server and builds up a string array of all the users in the GAL.
Having got these addresses it then attempts to login to each individual
mailbox and extract the email addresses in the Contacts folder individual
mailbox which it writes out to a text file.

If you're thinking that this all sounds a bit nefarious then I wouldn't
blame you but let me assure that it isn't. The generated text file is one
of
the criteria that the incoming mail filter uses to decide whether a mail
message should be rejected or left through - simple as that.

I chose CDO for two reasons, one was that I wanted to provide some
independence from different Outlook versions and secondly I wanted to
bypass
the annoying dialogs that have become a "feature" of Outlook in recent
versions. However I am experiencing some issues which I am hoping that
someone may be able to help me with...

1. The Outlook security dialog is still coming up! This was one of the
reasons behind not using Outlook day one and instead using CDO. The line
that causes the dialog to come up is:

aeAddressEntry = (MAPI.AddressEntry)aesAdressEntries.get_Item(i);

where:
aeAddressEntry is a MAPI.AddressEntry
aesAdressEntries is a MAPI.AddressEntries collection
i is merely a loop counter

2. I am being prompted for a login for each mailbox, despite the fact that
the ID that the process is running under has Admin privileges - why is
this?
I try to type acceptable credentials into it but the dialog keeps coming
up
again. WhenI eventually cancel it the error that comes back is
MAPI_E_FAILONEPROVIDER.

3. According to the MSKB (cannot remember the KB#) use of CDO through C#
is
not supported - if this is indeed the case what am I better off using?

Any help and pointers welcome - much thanks!

ATB,
Derek

"It's all fun and games till someone loses an eye..."
Derek Noonan, Technical Director, ntech.ie

Nov 16 '05 #2
Nicholas,

Thanks very much for answering - I really appreciate it!

1.
I think that the suggestion that you've given is worthwhile and I will
certainly look into it. Wouldn't it be cool thogh if you could "sign" the C#
code (like you would do say for registry access with
RegistryPermissionAttribute) and then let it have unfettered access?

2.
The code to log in is as follows:

// Read the info from the app.config file and build a ProfileInfo string
strServer = ConfigurationSettings.AppSettings["ExchangeServer"];
strUserName = ConfigurationSettings.AppSettings["UserName"];
strProfileInfo = strServer + "\n" + strUserName;

msMain = new MAPI.SessionClass();
..
..
..
try
{
msMain.Logon(Missing.Value, Missing.Value,false, true, Missing.Value, true,
strProfileInfo);
}
catch (COMException ce)
{
MessageBox.Show(ce.Message);
}

3.
I can't rem the URL now, but there was a table with the different means of
accessing Exchange, and whether or not they were supported:

CDO Not supported
CDOEX Supported
WebDav Supported
etc.

See,I don't really need to be client-side at all. If I could query the
server directly then that'd suit me much better. Would WebDav be the thing
that I should be looking at?
--

ATB,
Derek
|
snipped by Derek

|
Nov 16 '05 #3
Derek,

The WEBDav interface could be a better solution for you. The caveat is,
do you have your exchange server set up to provide that interface?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Noonan, Derek" <derek_noonan_at_hotmail_dot_com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Nicholas,

Thanks very much for answering - I really appreciate it!

1.
I think that the suggestion that you've given is worthwhile and I will
certainly look into it. Wouldn't it be cool thogh if you could "sign" the
C# code (like you would do say for registry access with
RegistryPermissionAttribute) and then let it have unfettered access?

2.
The code to log in is as follows:

// Read the info from the app.config file and build a ProfileInfo string
strServer = ConfigurationSettings.AppSettings["ExchangeServer"];
strUserName = ConfigurationSettings.AppSettings["UserName"];
strProfileInfo = strServer + "\n" + strUserName;

msMain = new MAPI.SessionClass();
.
.
.
try
{
msMain.Logon(Missing.Value, Missing.Value,false, true, Missing.Value,
true, strProfileInfo);
}
catch (COMException ce)
{
MessageBox.Show(ce.Message);
}

3.
I can't rem the URL now, but there was a table with the different means of
accessing Exchange, and whether or not they were supported:

CDO Not supported
CDOEX Supported
WebDav Supported
etc.

See,I don't really need to be client-side at all. If I could query the
server directly then that'd suit me much better. Would WebDav be the thing
that I should be looking at?
--

ATB,
Derek
|
snipped by Derek

|

Nov 16 '05 #4
Nicholas Paldino [.NET/C# MVP] wrote:
Derek,

The WEBDav interface could be a better solution for you. The caveat is,
do you have your exchange server set up to provide that interface?

Nicholas,

I just saw this now, using a different newsreader. Please accept my
apologies for not replying to you sooner.

How do I tell if my Exchange server is set up for WebDav? Is the
presence of OWA not enough?

ATB,
Derek

"It's all fun and games till someone loses an eye..."
Derek Noonan, Technical Director, ntech.ie
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Arno R | last post by:
Hi all, This is a repost of a message posted at october 6. The answer I got was about MapiMessages.AttachmentIndex. I think I need the MSMAPI32.OCX to use this. (I don't have this file on my PC)...
3
by: Adam | last post by:
I've posted about this previously, but failed to receive a satisfactory response, so have included a code sample: I am trying to receive messages from an HTML viewer control in compact.net (c#),...
0
by: Doug | last post by:
This is a repost of an item that I still cannot resolve. I have 3 combo boxes. The first leads to the second to the third. When I have selected a value in the second box, the third box shows...
14
by: Steve McLellan | last post by:
Hi, Sorry to repost, but this is becoming aggravating, and causing me a lot of wasted time. I've got a reasonably large mixed C++ project, and after a number of builds (but not a constant...
5
by: Adrian Parker | last post by:
I've got the standard SqlCacheDependency working just fine , ie. I've defined (and encrypted) the connectionStrings section in the web.config, and I've also defined an an sqlCacheDependency in the...
2
by: Gerry | last post by:
I have a combo box and I can populate it with my class of dat (the class allows me to store each userid,username called - see code below I want the user to select the dropdown and see the...
2
by: Raj | last post by:
Hi, I have the following problem. I am displaying and printing a PDF file that is generated by my Application server. The print dialogs comes up correctly for the small PDF for the larger PDFs...
1
by: lecnac | last post by:
Sorry for the repost. I must have done something wrong when I tried to post my reply (I can't seem to find it). Anyway, I'd really appreciate any help that anyone could provide. My issue is...
0
by: sham | last post by:
Hi to all, Sorry for the repost. I asked this question about 2 weeks ago and I have had no reply. I tried on the IIS group, but still no luck. Basically, we have a web service that has now...
4
by: Dave Burns | last post by:
Hello, I am trying to specify a logical default value for a in a WCF Web Service using basicHttpBinding. I realize that the language defaults are: int - 0 string - null bool - false
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.