473,508 Members | 2,327 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cdo mapi.session & streamwriter error

Hi,

I have an app, written in c#, that checks an email inbox (using
cdo/mapi) and does some processing.

I've written a function "WriteToLogFile (string text, bool onConsole)"
that checks whether the logfile exists (creates it if not), appends
the text to the file, closes the file and displays it on the console,
if required. It uses StreamWriter to accomplish this.

There is another function "CheckEmail()" that logs into the email
account, processes the email and logs out.

The program does what I want, except it can't append to the log file
after a it logs into the email account. Displaying on the Console
_always_ works.

I'll show some pseudo code to explain it better:

Main()
{
WriteToLogFile("1 start Main", true);
CheckEmail();
WriteToLogFile("8 end Main", true);
}

CheckMail()
{
WriteToLogFile("2 start CheckMail", true);
// log on to email account
Object vEmpty = Missing.Value;
Session oSession = new Session();
WriteToLogFile("3 b4 logon", true);

// \/ \/ \/ these get commented out later
oSession.Logon(strProfileName, strProfilePassword, vEmpty, true,
vEmpty, vEmpty, vEmpty);
WriteToLogFile("4 aft logon", true);

// do some stuff...
WriteToLogFile("5 logging off...", true);
oSession.Logoff();
// ^^^ these get commented out later on

WriteToLogFile("6 ...gone", true);
WriteToLogFile("7 end CheckMail", true);
}

I hope that makes sense to you.

The console displays everything you'd expect:
1 start Main
2 start CheckMail
3 b4 logon
4 aft logon
5 logging off...
6 ...gone
7 end CheckMail
8 end Main

but the log file only displays:
1 start Main
2 start CheckMail
3 b4 logon

If I don't logon and process the emails, the log file works again:
1 start Main
2 start CheckMail
3 b4 logon
7 end CheckMail
8 end Main

To my mind, it would seem that when I open a session the StreamWriter
fails to work.

Does anybody know that I'm doing wrong or how to fix it?

PS I'm using .NET v1.1.4322, CDO 1.2.1 on a Win 2K machine connecting
to an exchange server.

Cheers,

Sandy

Jul 21 '05 #1
0 1310

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

Similar topics

1
8745
by: V.C.Sekhar | last post by:
Hi there, Can any one please help in getting me Python-Outlook programming issue clarified. I just wanted to do the following using Python: 1)Open a New Oulook Mail Window
7
4179
by: Ottar | last post by:
I've made a program sorting incomming mail in public folder. The function runs every minute by using the form.timer event. In Access XP it runs for weeks, no problem. Access 2003 runs the same...
4
5012
by: Ottar | last post by:
Error: 80040108 after 380 CreateObject("MAPI.Session") Function MAPI_Test2() Dim i As Integer Dim MySession As MAPI.Session i = 0 While (i < 2000) Set MySession =...
0
1121
by: Grahame | last post by:
Hi, I have an app, written in c#, that checks an email inbox (using cdo/mapi) and does some processing. I've written a function "WriteToLogFile (string text, bool onConsole)" that checks...
0
1418
by: Kevin Quigley | last post by:
Hi, I have a web page that will send emails to various addresses, I've tried using the SmtpMail class but no matter what I try it will not work. I have an asp page that does actually work...
0
2178
by: PhilHip | last post by:
I've written a Windows service in VB.Net that accesses the global address list to obtain all the entries to store them in a local database. The GAL is accessed using the MS Exchange profile on the...
0
282
by: Sandy Beach | last post by:
Hi, I have an app, written in c#, that checks an email inbox (using cdo/mapi) and does some processing. I've written a function "WriteToLogFile (string text, bool onConsole)" that checks...
1
2844
by: bobh | last post by:
Hi All, I've been using this function which I got from here for some time now in two of my AccessXP multiusers applications and it has worked without issue until lately it has stopped functioning...
15
8311
by: squrel | last post by:
Hi everyone.. i need ur help once more time.... i have a form called reminder..in tht form i have: txtid, txtcaseid, txtreminder, cmbremindby(system or user), txtremindto, dtpreminddt,...
0
7224
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
7323
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,...
0
7380
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...
1
7039
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...
0
7494
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...
0
4706
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...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1553
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 ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.