Connecting Tech Pros Worldwide Forums | Help | Site Map

[REPOST] Using CDO from C#

Noonan, Derek
Guest
 
Posts: n/a
#1: Nov 16 '05
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


Nicholas Paldino [.NET/C# MVP]
Guest
 
Posts: n/a
#2: Nov 16 '05

re: [REPOST] Using CDO from C#


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]
- mvp@spam.guard.caspershouse.com


"Noonan, Derek" <derek_noonan_at_hotmail_dot_com> wrote in message
news:%23NA6OtWoEHA.3556@TK2MSFTNGP10.phx.gbl...[color=blue]
> 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
>[/color]


Noonan, Derek
Guest
 
Posts: n/a
#3: Nov 16 '05

re: [REPOST] Using CDO from C#


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
|[color=blue]
> snipped by Derek[/color]
|


Nicholas Paldino [.NET/C# MVP]
Guest
 
Posts: n/a
#4: Nov 16 '05

re: [REPOST] Using CDO from C#


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]
- mvp@spam.guard.caspershouse.com

"Noonan, Derek" <derek_noonan_at_hotmail_dot_com> wrote in message
news:%23aeTUXXoEHA.556@tk2msftngp13.phx.gbl...[color=blue]
> 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
> |[color=green]
>> snipped by Derek[/color]
> |
>[/color]


Noonan, Derek
Guest
 
Posts: n/a
#5: Nov 16 '05

re: [REPOST] Using CDO from C#


Nicholas Paldino [.NET/C# MVP] wrote:[color=blue]
> 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?
>
>[/color]
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
Closed Thread