473,659 Members | 2,591 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "WriteToLog File (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, strProfilePassw ord, 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 1124

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

Similar topics

1
8793
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
1319
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 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.
7
4192
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 code for 6 hours and stops. I've found the problem to be the Set MySession = CreateObject("MAPI.Session")
4
5033
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 = CreateObject("MAPI.Session") Debug.Print i
9
4583
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 streamwriter, what you have read into a streamReader? and also can someone explain how they work in simple terms -- The Matrix Insurrection
3
2837
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 additionally pictures of the product are stored in an images subfolder and the database holds the file name of the relevant picture. The user can then click a button to display the picture in a pop-up window and also another button to email the potential...
1
8136
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 Outlook Express 6 and Thunderbird 1.5, but it doens't work at all with Microsoft Outlook 2007. I keep getting this message: "WindowsError: MAPI error 2". I don't want to use Extended MAPI because it doesn't support thunderbird not OE. Therefore,...
1
2851
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 on several user pc's and I don't know why. I've asked our PC Services group what they changed on the pc's that this does not work on and they say 'nothing'. Well something has changed cause this did work at one time. When I step thru it in...
15
8358
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, MAPISession1, MAPIMessages1, cmdReminder in this case i have to set some fix reminder and fix date for every month tht automatically send by the system to some particular people... i dont knw anything abt mapi control and have never used tht... got some...
0
8339
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
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...
1
8535
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
8629
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
7360
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5650
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
4176
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...
0
4338
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1739
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.