473,385 Members | 2,210 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,385 software developers and data experts.

new MAPI.Session() does not work!?!?!?

I am writing a program in C# which accesses data from Exchange. Code
snippets have been copied from a VB-program.

The VB-program does the following:

'create session and logon
objSession = CreateObject("MAPI.Session")

After this, everyhing works fine.

In c# this looks like:

'create session and logon
objSession = new MAPI.Session();

And this does not work!?!? I get an error stating that Outlook is not
the default client or that the mail client cannot fullfil the
messaging request. Then i also get an exception: ClassFactory cannot
supply requested class.

Can anyone help me on this one? Everything concentrates on the
creation of the session object. In VB.NET it works, in C# not?
Nov 15 '05 #1
2 8556
Gerry,

I forgot to mention, the reason it doesn't work is that MAPI.Session
(when imported) is the name of an interface, not a class. VB6 obfuscated
classes and interfaces (quite poorly I might add). You can create an
instance of MAPI.SessionClass and it should work.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Gerry" <ge*****************@logicacmg.com> wrote in message
news:49**************************@posting.google.c om...
I am writing a program in C# which accesses data from Exchange. Code
snippets have been copied from a VB-program.

The VB-program does the following:

'create session and logon
objSession = CreateObject("MAPI.Session")

After this, everyhing works fine.

In c# this looks like:

'create session and logon
objSession = new MAPI.Session();

And this does not work!?!? I get an error stating that Outlook is not
the default client or that the mail client cannot fullfil the
messaging request. Then i also get an exception: ClassFactory cannot
supply requested class.

Can anyone help me on this one? Everything concentrates on the
creation of the session object. In VB.NET it works, in C# not?

Nov 15 '05 #2
Gerry,

You might want to use CreateObject in C# as well, through the
Microsoft.VisualBasic library. You could set a reference to
Microsoft.VisualBasic and then access the static CreateObject method through
the Interaction class in the Microsoft.VisualBasic namespace. This should
give you the same results.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Gerry" <ge*****************@logicacmg.com> wrote in message
news:49**************************@posting.google.c om...
I am writing a program in C# which accesses data from Exchange. Code
snippets have been copied from a VB-program.

The VB-program does the following:

'create session and logon
objSession = CreateObject("MAPI.Session")

After this, everyhing works fine.

In c# this looks like:

'create session and logon
objSession = new MAPI.Session();

And this does not work!?!? I get an error stating that Outlook is not
the default client or that the mail client cannot fullfil the
messaging request. Then i also get an exception: ClassFactory cannot
supply requested class.

Can anyone help me on this one? Everything concentrates on the
creation of the session object. In VB.NET it works, in C# not?

Nov 15 '05 #3

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

Similar topics

4
by: Kurt | last post by:
Hi I am using CDO 1.21 from C# in order to iterate through the entries in a users outlook address book (as OOM was too slow). Basically I take the Name field from each "message" and insert it into...
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...
1
by: Jay McGrath | last post by:
Help - trying to send a simple text email with with as little user intervention. I am trying to create a button in my Access application that will automatically send a simple text email. It...
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 =...
0
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...
4
by: Brian Hampson | last post by:
I recently upgraded to Outlook 2007 B2TR and have found that I can no longer code against MAPI.DLL It's gone :( Using C#, I used to get the MAPI session, and from that I could change the out of...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.