🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #12522

Re: MapiResolveName: really necesary?

#12522
From: Dennis Jones
Date: Mon, 01 Dec 2003 17:15
67 lines
2974 bytes
"Fernando" <frr@easyjob.net> wrote in message
news:g97msv4nlj2o10dk4rrvkh6t71o09gcmfg@4ax.com...
> On Sat, 29 Nov 2003 14:33:27 -0800, "Dennis Jones" <djones@nospam.com>
wrote:
>
> >
> >"Fernando" <frr@easyjob.net> wrote in message
> >news:5kugsvouqe1sref2h2banvk4tiqo8v6tds@4ax.com...
> >> Hi,
> >>
> >> Is it really necsary to call MapiResolveName() before calling
> >> MapiSendMessage()?
> >>
> >> I'm not sure if I understand the need of using it....
> >
> >I have found that it *is necessary* when sending mail via Microsoft
Outlook,
> >but must *not* be used when using other mail clients, such as Outlook
> >Express or Netscape.
> >
> >I don't know why this is true.  I only know that it is what I had to do
to
> >get MAPI to work with different mail clients.
>
> Hhhmm... And how am I suposed to know what email client is present?

Read the registry.  All you care about is the "default" mail client:

      std::auto_ptr<TRegistry> pRegistry(new TRegistry);
      pRegistry->RootKey = HKEY_LOCAL_MACHINE;
      if ( !pRegistry->OpenKey( "\\Software\\Clients\\Mail", false ) )
return false;
      AnsiString DefaultMailClient;
      try
      {
        try
        {
          DefaultMailClient = pRegistry->ReadString( "" );
        }
        catch(...)
        {
          return false;
        }
      }
      __finally
      {
        pRegistry->CloseKey();
      }

      if ( DefaultMailClient == "Microsoft Outlook" )
      {
        // MapiResolveName allows MapiSendMail to work with Outlook, but
causes
        // MapiSendMail to fail when Outlook Express is used.

        error = MapiResolveName( Session, (unsigned int)Application->Handle,
(char *)EmailAddress, /*MAPI_DIALOG*/0, 0, pMapiRecip );
        if ( error != SUCCESS_SUCCESS )
        {
          pMapiRecip = 0;
          return false;
        }
        note.lpRecips = pMapiRecip;
      }

- Dennis
Technical Details
Message-ID: <3fcb7715$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <5kugsvouqe1sref2h2banvk4tiqo8v6tds@4ax.com> <3fc91eb8@newsgroups.borland.com> <g97msv4nlj2o10dk4rrvkh6t71o09gcmfg@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,5c791715cec446ea
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-12-01 09:29:32 PST
From: "Dennis Jones" <djones@nospam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <5kugsvouqe1sref2h2banvk4tiqo8v6tds@4ax.com> <3fc91eb8@newsgroups.borland.com> <g97msv4nlj2o10dk4rrvkh6t71o09gcmfg@4ax.com>
Subject: Re: MapiResolveName: really necesary?
Date: Mon, 1 Dec 2003 09:15:01 -0800
Lines: 69
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 204.200.27.7
Message-ID: <3fcb7715$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1070298901 204.200.27.7 (1 Dec 2003 09:15:01 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail