Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to give a MAPIOBJECT from C# to a Delphi DLL

0 views
Skip to first unread message

Hans Schmidt

unread,
Oct 23, 2009, 4:04:22 AM10/23/09
to
Hello,

at the moment i'm writing a COM-Addin in C#. I need to get the actual
profile name.
With this line: Application.Session.CurrentUser.Name i can get the
profile name with Outlook 2007.
Unfortunately that doesn't work with Outlook 2003.

As a workaround i thought i write a Delphi DLL where i get the actual
profile name with extended MAPI.

My question is if it is possible to pass
Application.Session.MAPIOBJECT to the Delphi DLL. How can
i archieve this?


Greets Hans

Dmitry Streblechenko

unread,
Oct 23, 2009, 12:46:31 PM10/23/09
to
Pass it as IUnknown, then in your Delphi code QI it for IMAPISession.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Hans Schmidt" <suffp...@googlemail.com> wrote in message
news:ff8b1bff-dd48-46ec...@m1g2000vbi.googlegroups.com...

Hans Schmidt

unread,
Oct 24, 2009, 2:49:46 AM10/24/09
to
Hi,

do you have or anyone else an example how to get the IUnknown from
Application.Session.MAPIOBJECT? I can't find IUnknown in C#.


Greets Hans

On 23 Okt., 18:46, "Dmitry Streblechenko" <dmi...@dimastr.com> wrote:
> Pass it as IUnknown, then in your Delphi code QI it for IMAPISession.
>
> --

> Dmitry Streblechenko (MVP)http://www.dimastr.com/


> OutlookSpy  - Outlook, CDO
> and MAPI Developer Tool

> -"Hans Schmidt" <suffpor...@googlemail.com> wrote in message

Dmitry Streblechenko

unread,
Oct 26, 2009, 1:35:27 PM10/26/09
to
Declare it as object in .Net.
In your Delphi COM object OleVariant would work sure, IUnknown should alse
work I think.

--
Dmitry Streblechenko (MVP)


http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-

"Hans Schmidt" <suffp...@googlemail.com> wrote in message

news:3bc5dd29-bfac-491d...@p36g2000vbn.googlegroups.com...

Hans Schmidt

unread,
Oct 27, 2009, 8:25:33 AM10/27/09
to
My procedure in Delphi looks that way:

procedure getProfile(Intf: IUnknown); stdcall;
const
pbGlobalProfileSectionGuid : TMAPIUID = (ab:($13,$DB,$B0,$C8,$AA,
$05,$10,$1A,$9B,$B0,$00,$AA,$00,$2F,$C4,$5A));
var
lppprofsect : Iprofsect;
propProfile : PSPropValue;
value : String;
hr : Hresult;
session : IMapiSession;
begin
value:='';

Intf.QueryInterface(IID_IMAPISession, session);

hr:=session.OpenProfileSection(PMAPIUID
(@pbGlobalProfileSectionGuid),IID_IProfSect,MAPI_MODIFY, lppProfSect);
if (hr = S_OK) then
begin
propprofile:=nil;

if (S_OK = HrGetOneProp(lppprofsect, PR_PROFILE_NAME,
propProfile)) then
value:=propprofile.value.lpsza;

if assigned(propprofile) then
mapifreebuffer(propprofile);
propprofile:=nil;
end
else
if (hr<>S_OK) then
begin
end;

lppProfSect:=nil;

ShowMessage(value);
end;

Passing the IUnknown works but while doing this:
Intf.QueryInterface(IID_IMAPISession, session);

i get a MAPI_E_CALL_FAILED error.

Does anyone know why?


Greets Hans

On 26 Okt., 18:35, "Dmitry Streblechenko" <dmi...@dimastr.com> wrote:
> Declare it as object in .Net.
> In your Delphi COM object OleVariant would work sure, IUnknown should alse
> work I think.
>
> --

Dmitry Streblechenko

unread,
Oct 27, 2009, 2:25:00 PM10/27/09
to
Is that in in-proc or out-of-proc executable? In the latter case, you must
call MAPIInitialize first.

--
Dmitry Streblechenko (MVP)


http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-

"Hans Schmidt" <suffp...@googlemail.com> wrote in message

news:663b0b7c-da50-4f98...@f16g2000yqm.googlegroups.com...

Hans Schmidt

unread,
Oct 28, 2009, 6:13:20 AM10/28/09
to
Thank you very much Mr. Streblechenko,

the solution was to call MapiInitialize. Now, everything works fine.


Greets Hans

the

On 27 Okt., 19:25, "Dmitry Streblechenko" <dmi...@dimastr.com> wrote:
> Is that in in-proc or out-of-proc executable? In the latter case, you must
> call MAPIInitialize first.
>
> --

0 new messages