473,387 Members | 1,611 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,387 software developers and data experts.

cdo mapi.seesion & 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,

Grahame
Nov 16 '05 #1
0 1116

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

Similar topics

1
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
0
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...
7
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
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 =...
9
by: ShadowOfTheBeast | last post by:
Hi, I have got a major headache understanding streamReader and streamWriter relationship. I know how to use the streamreader and streamwriter independently. but how do you write out using the...
3
by: Siv | last post by:
Hi, A little while ago I wrote a small program that allowed the user to view products from a database. The database holds the details of the products which can be viewed via a form and...
1
by: tomer.ha | last post by:
Hi there, I'd like to send emails from a Python program using Simple MAPI. I've tried this code: http://mail.python.org/pipermail/python-list/2004-December/298066.html and it works well with...
1
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
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
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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...
0
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...

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.