473,789 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[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.AddressEn try)aesAdressEn tries.get_Item( i);

where:
aeAddressEntry is a MAPI.AddressEnt ry
aesAdressEntrie s is a MAPI.AddressEnt ries 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_FAILONEP ROVIDER.

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 5247
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 "Administra tor 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.co m
"Noonan, Derek" <derek_noonan_a t_hotmail_dot_c om> wrote in message
news:%2******** ********@TK2MSF TNGP10.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.AddressEn try)aesAdressEn tries.get_Item( i);

where:
aeAddressEntry is a MAPI.AddressEnt ry
aesAdressEntrie s is a MAPI.AddressEnt ries 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_FAILONEP ROVIDER.

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
RegistryPermiss ionAttribute) 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 = ConfigurationSe ttings.AppSetti ngs["ExchangeServer "];
strUserName = ConfigurationSe ttings.AppSetti ngs["UserName"];
strProfileInfo = strServer + "\n" + strUserName;

msMain = new MAPI.SessionCla ss();
..
..
..
try
{
msMain.Logon(Mi ssing.Value, Missing.Value,f alse, 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.co m

"Noonan, Derek" <derek_noonan_a t_hotmail_dot_c om> wrote in message
news:%2******** *******@tk2msft ngp13.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
RegistryPermiss ionAttribute) 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 = ConfigurationSe ttings.AppSetti ngs["ExchangeServer "];
strUserName = ConfigurationSe ttings.AppSetti ngs["UserName"];
strProfileInfo = strServer + "\n" + strUserName;

msMain = new MAPI.SessionCla ss();
.
.
.
try
{
msMain.Logon(Mi ssing.Value, Missing.Value,f alse, 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
4734
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) My newsaccount wasn't working anymore until yesterday, so I'll try again. Question is: I know it is possible to send email with Access, but can one also automate the attachments?
3
1870
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#), but cannot use message window as the control's parent window, as this is invisible and so the html is not viewable! I have a code sample showing the problem at www.tenwisevirgins.com/Example.zip
0
2053
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 the available information based on the second combo box selection. But if I change my mind and select a different item in the second box, after the third box has been populated, the third box still retains the information that was previously...
14
2840
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 number) linking (and sometimes compiling) becomes immensely slow, and task manager shows that link.exe (or cl.exe) is barely using any processor time, but an awful lot of RAM (around 150-200MB). I'm going to keep an eye on page faults since I can't...
5
2448
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 caching section. So, in my code I add an item to the cache with an sqlCacheDependency, referencing the named sqlCacheDependency in the web.config and the database table it is to be based on (have enabled notificiations for that table). Fine. ...
2
1311
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 username - but also determine the UserID from what was selected (using DisplayName from the combo box?? I can populate the combo box without problems - BUT the user sees "System.object" in each item of the combobox not the username ***here is my clas...
2
1454
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 ,the print dialog for the Acrobat reader does not comes up. I believe this is because print method is called before the complete loading of the PDF document. <html> <Head> <script>
1
3704
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 quickly becoming more and more urgent. I've tried the code below using the server's local Administrator user name and password. This gets me past the Access denied error but gives me a User
0
1051
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 been re-written using Asp.net. The old web service calls were made using : http://MyCompany/soap/NewsService (i.e. without any extension). What I need to do is "redirect" http://MyCompany/soap/NewsService to
4
17282
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
9661
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10403
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10193
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9978
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6755
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5414
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4087
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2904
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.