A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Tags: , ,

Redemption+CBuilder: RDOSession.Logon MAPILogonEx-Error





 
 
Thread Tools Display Modes
  #1  
Old August 31st 06, 01:23 PM posted to microsoft.public.outlook.program_addins
tsahling@hausmannwynen.de
external usenet poster
 
Posts: 9
Default Redemption+CBuilder: RDOSession.Logon MAPILogonEx-Error

Hi!

I use Redemption 4.2 with C-Builder 5 via imported typelib.

I have the problem that a second usage of RDOSession.Logon returns an
EOleSysError with the message "Error in MAPILogonEx:
MAPI_E_NOT_INITIALIZED".

This is the code:

-----
::CoInitializeEx( 0, COINIT_MULTITHREADED );
// --
try
{
auto_ptrTOutlookApplication outlook( new TOutlookApplication( 0 )
);
// --
outlook-ConnectKind = ckNewInstance;
outlook-Connect();
// --
try
{
Variant draftMailEntryID;
// --
{
auto_ptrTRDOSession rdoSession( new TRDOSession( outlook.get()
) );
// --
rdoSession-Logon( "", "", false, true );
// --
try
{
Redemption_tlb::IRDOFolderPtr rdoDraftsFolder =
rdoSession-GetDefaultFolder( Outlook_tlb:lFolderDrafts );
Redemption_tlb::IRDOMailPtr rdoMail =
rdoDraftsFolder-Items-Add( Outlook_tlb:lMailItem );
// --
rdoMail-Import( WideString( m_vorlagenDatei ), type );
rdoMail-Subject = WideString( m_dokTitel );
rdoMail-Attachments-Add( m_pdfFilename );
rdoMail-Recipients-Add( m_kunEmail );
// --
rdoMail-Save();
// --
draftMailEntryID = rdoMail-EntryID;
}
__finally
{
rdoSession-Logoff();
}
}
// --
_NameSpacePtr comSession = outlook-GetNamespace( WideString(
"MAPI" ) );
// --
comSession-Logon( "", "", false, true );
// --
try
{
MailItemPtr mail = comSession-GetItemFromID( draftMailEntryID );

// --
mail-Display( true );
// --
mail-Close( olDiscard );
}
__finally
{
comSession-Logoff();
}
}
__finally
{
outlook-Disconnect();
}
}
__finally
{
::CoUninitialize();
}
----

This first time this code is executed, everything is fine. If the user
executes this code a second time, I get the error described above
(line: rdoSession-Logon( "", "", false, true );)

I tried already to wrap this code with
MAPIInitialize()/MAPIDeinitialize(), but the same error occurs.

Has anyone an idea what the problem might be?

Thanks!

Ads
  #2  
Old August 31st 06, 06:09 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 1,522
Default Redemption+CBuilder: RDOSession.Logon MAPILogonEx-Error

Are you sharing the same instance of IRDOSession between different threads?
What is TRDOSession? Is that your class?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

wrote in message
oups.com...
Hi!

I use Redemption 4.2 with C-Builder 5 via imported typelib.

I have the problem that a second usage of RDOSession.Logon returns an
EOleSysError with the message "Error in MAPILogonEx:
MAPI_E_NOT_INITIALIZED".

This is the code:

-----
::CoInitializeEx( 0, COINIT_MULTITHREADED );
// --
try
{
auto_ptrTOutlookApplication outlook( new TOutlookApplication( 0 )
);
// --
outlook-ConnectKind = ckNewInstance;
outlook-Connect();
// --
try
{
Variant draftMailEntryID;
// --
{
auto_ptrTRDOSession rdoSession( new TRDOSession( outlook.get()
) );
// --
rdoSession-Logon( "", "", false, true );
// --
try
{
Redemption_tlb::IRDOFolderPtr rdoDraftsFolder =
rdoSession-GetDefaultFolder( Outlook_tlb:lFolderDrafts );
Redemption_tlb::IRDOMailPtr rdoMail =
rdoDraftsFolder-Items-Add( Outlook_tlb:lMailItem );
// --
rdoMail-Import( WideString( m_vorlagenDatei ), type );
rdoMail-Subject = WideString( m_dokTitel );
rdoMail-Attachments-Add( m_pdfFilename );
rdoMail-Recipients-Add( m_kunEmail );
// --
rdoMail-Save();
// --
draftMailEntryID = rdoMail-EntryID;
}
__finally
{
rdoSession-Logoff();
}
}
// --
_NameSpacePtr comSession = outlook-GetNamespace( WideString(
"MAPI" ) );
// --
comSession-Logon( "", "", false, true );
// --
try
{
MailItemPtr mail = comSession-GetItemFromID( draftMailEntryID );

// --
mail-Display( true );
// --
mail-Close( olDiscard );
}
__finally
{
comSession-Logoff();
}
}
__finally
{
outlook-Disconnect();
}
}
__finally
{
::CoUninitialize();
}
----

This first time this code is executed, everything is fine. If the user
executes this code a second time, I get the error described above
(line: rdoSession-Logon( "", "", false, true );)

I tried already to wrap this code with
MAPIInitialize()/MAPIDeinitialize(), but the same error occurs.

Has anyone an idea what the problem might be?

Thanks!



  #3  
Old September 1st 06, 08:32 AM posted to microsoft.public.outlook.program_addins
tsahling@hausmannwynen.de
external usenet poster
 
Posts: 9
Default Redemption+CBuilder: RDOSession.Logon MAPILogonEx-Error

Are you sharing the same instance of IRDOSession between different threads?

No, the routine is executed once at a time.

But because of your question I had an idea and tried CoInitializeEx
with parameter COINIT_APARTMENTTHREADED. Now I don't get the exception
and everything works fine!

What is TRDOSession? Is that your class?


That's a class generated by C-Builder from the Redemption type lib. It
inherits TOleServer and provides instant access to the interface object
behind it (and its events).

Thanks for your quick reply!

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
can't logon newber Outlook - General Queries 1 May 16th 06 12:37 PM
logon credentials Johnse Outlook - Installation 1 May 14th 06 05:45 PM
Prompt for Logon Question UCLA MCCS Outlook - Installation 0 April 4th 06 11:18 PM
Outlook XP Logon Issue Himalaya Outlook - General Queries 0 January 25th 06 03:18 PM
why am I getting logon box Bob Outlook Express 6 January 17th 06 11:35 PM


All times are GMT +1. The time now is 07:05 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2008 Outlook Banter, part of the NewsgroupBanter project.
The comments are property of their posters.
Yugioh - Debt - Mortgages - Loans - Remortgages