🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.web
25 messages
25 total messages Started by RS Sun, 26 Feb 2006 19:43
How display MAPIMAIL
#955
Author: RS
Date: Sun, 26 Feb 2006 19:43
11 lines
1119 bytes
Hello !

How to display MAPIMAIL window with attachment ? (Microsoft Outlook or
Outlook Express new message window)

Like this :

http://www.hawaii.rr.com/rrhelp/email/PC/IE5/addressbook/media/6click%20to%20from%20new%20message%20window.gif


Thanks ;)
Re: How display MAPIMAIL
#956
Author: Remy Lebeau (TeamB)
Date: Mon, 27 Feb 2006 20:27
11 lines
1148 bytes
"RS" <rs.reloaded@wanadoo.fr> wrote in message
news:4402040f@newsgroups.borland.com...

> How to display MAPIMAIL window with attachment ?
> (Microsoft Outlook or Outlook Express new message window)

Look at the MapiSendMail() function.


Gambit
Re: How display MAPIMAIL
#957
Author: HF
Date: Mon, 27 Feb 2006 23:10
20 lines
1498 bytes
� "RS" <rs.reloaded@wanadoo.fr> ������ ��� ������ 
news:4402040f@newsgroups.borland.com...
> Hello !
>
> How to display MAPIMAIL window with attachment ? (Microsoft Outlook or
> Outlook Express new message window)
>
> Like this :
>
> http://www.hawaii.rr.com/rrhelp/email/PC/IE5/addressbook/media/6click%20to%20from%20new%20message%20window.gif

Maybe this can help you
   char* dest = "mailto : username@someServer.gr"; // Remove the spaces form 
dest string after mailto

   ShellExecute(this->Handle,"open",dest,"","",SW_SHOWNORMAL);


-minas 
Re: How display MAPIMAIL
#958
Author: RS
Date: Tue, 28 Feb 2006 20:21
43 lines
1885 bytes

Hi,

Many thanks for your answers, but :

- The MapiSendMail() function doesn't exist (Borland C++ Builder 6)

( with : include <mapi.h> )

- The "mailto :" function don't allow the attachment.

Another suggestion ?

Thanks a lot.

RS.



"HF" <(min_charATyahooPUTADOTgr)(HellenicFire)> a �crit dans le message de 
news: 440386d1@newsgroups.borland.com...
>
> � "RS" <rs.reloaded@wanadoo.fr> ������ ��� ������ 
> news:4402040f@newsgroups.borland.com...
>> Hello !
>>
>> How to display MAPIMAIL window with attachment ? (Microsoft Outlook or
>> Outlook Express new message window)
>>
>> Like this :
>>
>> http://www.hawaii.rr.com/rrhelp/email/PC/IE5/addressbook/media/6click%20to%20from%20new%20message%20window.gif
>
> Maybe this can help you
>   char* dest = "mailto : username@someServer.gr"; // Remove the spaces 
> form dest string after mailto
>
>   ShellExecute(this->Handle,"open",dest,"","",SW_SHOWNORMAL);
>
>
> -minas
> 
Re: How display MAPIMAIL
#959
Author: RS
Date: Tue, 28 Feb 2006 21:12
70 lines
2716 bytes
Hello,
I'm finally finding the following code :

But I don't know how I can integrated an attachment !   (for example : 
Edit1->Text = "c:\file.txt")
And how can I integrated the recipient email address (Edit2->Text = " 
address@company.com")

//-----------------------------------------  
TART  -----------------------------------
  TMapiMessage MapiMessage;
   Cardinal MError;

   MapiMessage.ulReserved = 0;
   MapiMessage.lpszSubject = "this is a test";
   MapiMessage.lpszNoteText = RichEdit1->Lines->Text.c_str();        // 
RichEdit1 contains the body message
   MapiMessage.lpszMessageType = NULL;
   MapiMessage.lpszDateReceived = NULL;
   MapiMessage.lpszConversationID = NULL;
   MapiMessage.flFlags = 0;
   MapiMessage.lpOriginator = NULL;
   MapiMessage.nRecipCount = 0;
   MapiMessage.lpRecips = NULL;        // How to put Edit2->Text on lpRecips 
???
   MapiMessage.nFileCount = NULL;
   MapiMessage.lpFiles = NULL;          // How to put Edit1->Text on lpFiles 
???


   MError = MapiSendMail(0, reinterpret_cast<unsigned 
int>(Application->Handle),
                 MapiMessage, MAPI_DIALOG | MAPI_LOGON_UI | 
MAPI_NEW_SESSION, 0);

   if (MError)
    ShowMessage("Error !");

//-----------------------------  
END -----------------------------------------------



I search on the net, but I don't find the solution !

Thanks ;)
RS

I'm using Borland  C++ Builder 6 enterprise



"RS" <rs.reloaded@wanadoo.fr> a �crit dans le message de news: 
4402040f@newsgroups.borland.com...
> Hello !
>
> How to display MAPIMAIL window with attachment ? (Microsoft Outlook or
> Outlook Express new message window)
>
> Like this :
>
> http://www.hawaii.rr.com/rrhelp/email/PC/IE5/addressbook/media/6click%20to%20from%20new%20message%20window.gif
>
>
> Thanks ;)
>
>
>
>
> 
Re: How display MAPIMAIL
#960
Author: HF
Date: Tue, 28 Feb 2006 22:58
78 lines
3218 bytes
� "RS" <rs.reloaded@wanadoo.fr> ������ ��� ������ 
news:4404bbf5$1@newsgroups.borland.com...
> Hello,
> I'm finally finding the following code :
>
> But I don't know how I can integrated an attachment !   (for example : 
> Edit1->Text = "c:\file.txt")
> And how can I integrated the recipient email address (Edit2->Text = " 
> address@company.com")
>

A MapiFileDesc structure holds information about a message attachment
so add this
   MapiFileDesc tmp={0};
   tmp.lpszPathName= "C:\\yourFile.txt";
   tmp.nPosition = -1;
   tmp.lpszFileName ="";

A MapiRecipDesc structure holds information about a message sender or 
recipient
so add the following for recipient (you can use an array for more 
recipients)

   MapiRecipDesc rec={0};
   rec.ulRecipClass = MAPI_TO;
   rec.lpszAddress = "SMTP:tofriend@server.gr";


>  TMapiMessage MapiMessage;

Instead
MapiMessage MapiMessage;

>   Cardinal MError;
>
>   MapiMessage.ulReserved = 0;
>   MapiMessage.lpszSubject = "this is a test";
>   MapiMessage.lpszNoteText = RichEdit1->Lines->Text.c_str();        // 
> RichEdit1 contains the body message
>   MapiMessage.lpszMessageType = NULL;
>   MapiMessage.lpszDateReceived = NULL;
>   MapiMessage.lpszConversationID = NULL;
>   MapiMessage.flFlags = 0;
>   MapiMessage.lpOriginator = NULL;
>   MapiMessage.nRecipCount = 0;
>   MapiMessage.lpRecips = NULL;        // How to put Edit2->Text on 
> lpRecips ???
>   MapiMessage.nFileCount = NULL;
>   MapiMessage.lpFiles = NULL;          // How to put Edit1->Text on 
> lpFiles

Instead

MapiMessage.nRecipCount = 1;
MapiMessage.lpRecips = &rec;
MapiMessage.nFileCount = 1;
MapiMessage.lpFiles = &tmp

>   MError = MapiSendMail(0, reinterpret_cast<unsigned 
> int>(Application->Handle),
>                 MapiMessage, MAPI_DIALOG | MAPI_LOGON_UI | 
> MAPI_NEW_SESSION, 0);

Instead you can use
   MError = MAPISendMail(0L,0L , &MapiMessage,MAPI_DIALOG, 0L);

//******** Put also this *******//
MAPIFreeBuffer(&tmp);
MAPIFreeBuffer(&rec);
//****************

>   if (MError)
>    ShowMessage("Error !");

I hope ididn't miss something :-)

-minas 
Re: How display MAPIMAIL
#961
Author: Remy Lebeau (TeamB)
Date: Wed, 01 Mar 2006 01:34
15 lines
1270 bytes
"RS" <rs.reloaded@wanadoo.fr> wrote in message
news:4404aff1$1@newsgroups.borland.com...

> - The MapiSendMail() function doesn't exist (Borland C++ Builder 6)

Yes, it does.

> with : include <mapi.h>

Did you try looking in that file yet?  I assure you that MAPISendMail() is
in it.


Gambit
Re: How display MAPIMAIL
#963
Author: Remy Lebeau (TeamB)
Date: Wed, 01 Mar 2006 01:54
70 lines
3156 bytes
"RS" <rs.reloaded@wanadoo.fr> wrote in message
news:4404bbf5$1@newsgroups.borland.com...

> But I don't know how I can integrated an attachment !

I am guessing that you did not read the documentation yet, correct?
MAPISendMail() is in the Win32 API documentation:

    MAPISendMail

http://msdn.microsoft.com/library/en-us/mapi/html/4cb46e35-cd8f-4c6a-9a10-2a3f63e84ecd.asp

    MapiMessage

http://msdn.microsoft.com/library/en-us/mapi/html/8dce3399-176b-48c9-acff-ccdeedbc8033.asp


>    MapiMessage.lpszNoteText = RichEdit1->Lines->Text.c_str();

That code will not work like that.  You are retreiving a char* pointer for a
temporary AnsiString that goes out of scope immediately, thus leaving the
MAPI structure pointing to invalid memory.  You will need to make a copy of
the Text in order to keep the data in memory long enough for MAPI to use it.
The easiest way is to just use an AnsiString variable that remains in scope,
ie:

    AnsiString body = RichEdit1->Lines->Text;
    MapiMessage.lpszNoteText = body.c_str();

>    MapiMessage.nRecipCount = 0;
>    MapiMessage.lpRecips = NULL;        // How to put Edit2->Text on
lpRecips
> ???

Had you read the documentation, you would see that the lpRecips member is an
array of MapiRecipDesc structures.  So, to specify a single recipient, you
simply declare an instance of the MapiRecipDesc structure, fill it in as
needed, and then assign its memory pointer to the lpRecips member, ie:

    AnsiString addr = "SMTP:" + Edit2->Text;

    MapiRecipDesc recip = {0};
    recip.ulRecipClass = MAPI_TO;
    recip.lpszAddress = addr.c_str();

    MapiMessage.nRecipCount = 1;
    MapiMessage.lpRecips = &recip;

>    MapiMessage.nFileCount = NULL;
>    MapiMessage.lpFiles = NULL;          // How to put Edit1->Text on
lpFiles
> ???

The same applies for files as well, except with the MapiFileDesc structure
instead:

    AnsiString path = Edit1->Text;
    AnsiString filename = ExtractFileName(path);

    MapiFileDesc file = {0};
    file.nPosition = 0xFFFFFFFF;
    recip.lpszPathName = path.c_str();
    recip.lpszFileName = filename.c_str();

    MapiMessage.nFileCount = 1;
    MapiMessage.lpFiles = &file;


Gambit
Re: How display MAPIMAIL
#962
Author: Remy Lebeau (TeamB)
Date: Wed, 01 Mar 2006 01:56
18 lines
1687 bytes
"HF" <(min_charATyahooPUTADOTgr)(HellenicFire)> wrote in message
news:4404d5b0@newsgroups.borland.com...

> //******** Put also this *******//
> MAPIFreeBuffer(&tmp);
> MAPIFreeBuffer(&rec);
> //****************

Do not do that.  In the code you provided, none of the structure members are
dynamically allocated, so there is nothing to free.  The only time you
should ever call MAPIFreeBuffer() is when freeing memory that the MAPI
system itself allocated, which is not the case here.  The only functions
that allocate memory which has to be freed by the user's code is
MAPIReadMail(), MAPIAddress(), and MAPIResolveName().


Gambit
Re: How display MAPIMAIL
#964
Author: HF
Date: Wed, 01 Mar 2006 08:59
17 lines
1519 bytes
� "Remy Lebeau (TeamB)" <no.spam@no.spam.com> ������ ��� ������ 
news:4404ff0d$1@newsgroups.borland.com...
>
> "HF" <(min_charATyahooPUTADOTgr)(HellenicFire)> wrote in message
> news:4404d5b0@newsgroups.borland.com...
>
>> //******** Put also this *******//
>> MAPIFreeBuffer(&tmp);
>> MAPIFreeBuffer(&rec);
>> //****************
>
> Do not do that.  In the code you provided, none of the structure members 
> are


Thanks, you are right :-) 
Re: How display MAPIMAIL
#965
Author: RS
Date: Wed, 01 Mar 2006 20:27
174 lines
6936 bytes
YES !!!
Many thanks to HF and Remy Lebeau, very very good !!

My goal is to appear the MAPI Windows (Outlook Express), and the user can 
modify subject and body, and can press Send button.

I'm finally finding this following code
This code can open Outlook Express (if he's default MAPI software) with 2 
attachments (c:\test.pdf and c:\test.txt)
This code works perfectly if I put 0 instead of MAPI_DIALOG in this function 
:
pfnSendMail(lHnd,0, &mapimsg,MAPI_DIALOG,0);
the mail is send directly with no confirmation.

My goal is not to send directly, I want the MAPI window to modify subject 
and body, and click send button  to send the mail.

If I Put MAPI_DIALOG instead of  0 in pfnSendMail()  , the MAPI windows does 
correctly appear, and the attachments does appear correctly,  but I can't 
modify subject, and I can't click to the send button.

I espere that I express myself clearly ! lol  (excuse me ! I'm French ! lol)

This is my code :

//------------------------------------------------------------------
 LPMAPISENDMAIL pfnSendMail;
   MapiRecipDesc  rdOriginator;
   MapiRecipDesc  rdRecipient[1];
   LPMAPILOGOFF   pfnLogoff;
   LPMAPILOGON    pfnLogon;
   MapiMessage    mapimsg;
   HINSTANCE      hDll;
   LHANDLE        lHnd;
   MapiFileDesc   mapifiledesc[2];

   if(NULL == (hDll = LoadLibrary(TEXT("MAPI32.DLL"))))
   {
       _tprintf(TEXT("could not load mapi32.dll, ErrorCode: %u"), 
GetLastError());
   }
   pfnLogon    = (LPMAPILOGON)GetProcAddress(hDll, "MAPILogon");
   pfnLogoff   = (LPMAPILOGOFF)GetProcAddress(hDll, "MAPILogoff");
   pfnSendMail = (LPMAPISENDMAIL)GetProcAddress(hDll, "MAPISendMail");

   pfnLogon(0, NULL, NULL, 0, 0, &lHnd);

   mapimsg.ulReserved   = 0;
   mapimsg.lpszSubject  = "Here the subject";
   mapimsg.lpszNoteText = "Here is the Body Text";
   mapimsg.lpszMessageType    = NULL;
   mapimsg.lpszDateReceived   = NULL;
   mapimsg.lpszConversationID = NULL;
   mapimsg.flFlags      = MAPI_UNREAD;
   mapimsg.lpOriginator = &rdOriginator;
   mapimsg.nRecipCount  = NUM_ELEMENTS(rdRecipient);
   mapimsg.lpRecips     = rdRecipient;
   mapimsg.nFileCount   = 2;
   mapimsg.lpFiles      = &mapifiledesc[0];

   rdOriginator.ulReserved   = 0;
   rdOriginator.ulRecipClass = MAPI_ORIG;
   rdOriginator.lpszName     = "rdOriginator";
   rdOriginator.lpszAddress  = "adresse@expediteur.com"; // Expediteur
   rdOriginator.ulEIDSize    = 0;
   rdOriginator.lpEntryID    = NULL;

   rdRecipient[0].ulReserved   = 0;
   rdRecipient[0].ulRecipClass = MAPI_TO;
   rdRecipient[0].lpszName     = NULL;
   rdRecipient[0].lpszAddress  = "adresse@destinataire.com";   // 
Destinataire
   rdRecipient[0].ulEIDSize    = 0;
   rdRecipient[0].lpEntryID    = NULL;

   mapifiledesc[0].ulReserved   = 0;
   mapifiledesc[0].flFlags      = 0;
   mapifiledesc[0].nPosition    = -1;
   mapifiledesc[0].lpszPathName = "C:\\test.txt";
   mapifiledesc[0].lpszFileName = "test.txt";
   mapifiledesc[0].lpFileType   = 0;

   mapifiledesc[1].ulReserved   = 0;
   mapifiledesc[1].flFlags      = 0;
   mapifiledesc[1].nPosition    = -1;
   mapifiledesc[1].lpszPathName = "C:\\test.pdf";
   mapifiledesc[1].lpszFileName = "test.pdf";
   mapifiledesc[1].lpFileType   = 0;
   pfnSendMail(lHnd,0, &mapimsg,MAPI_DIALOG,0);
   pfnLogoff(lHnd, 0, 0, 0);
   FreeLibrary(hDll);
//----------------------------------------------------------------------------



"Remy Lebeau (TeamB)" <no.spam@no.spam.com> a �crit dans le message de news: 
4404fe85$1@newsgroups.borland.com...
>
> "RS" <rs.reloaded@wanadoo.fr> wrote in message
> news:4404bbf5$1@newsgroups.borland.com...
>
>> But I don't know how I can integrated an attachment !
>
> I am guessing that you did not read the documentation yet, correct?
> MAPISendMail() is in the Win32 API documentation:
>
>    MAPISendMail
>
> http://msdn.microsoft.com/library/en-us/mapi/html/4cb46e35-cd8f-4c6a-9a10-2a3f63e84ecd.asp
>
>    MapiMessage
>
> http://msdn.microsoft.com/library/en-us/mapi/html/8dce3399-176b-48c9-acff-ccdeedbc8033.asp
>
>
>>    MapiMessage.lpszNoteText = RichEdit1->Lines->Text.c_str();
>
> That code will not work like that.  You are retreiving a char* pointer for 
> a
> temporary AnsiString that goes out of scope immediately, thus leaving the
> MAPI structure pointing to invalid memory.  You will need to make a copy 
> of
> the Text in order to keep the data in memory long enough for MAPI to use 
> it.
> The easiest way is to just use an AnsiString variable that remains in 
> scope,
> ie:
>
>    AnsiString body = RichEdit1->Lines->Text;
>    MapiMessage.lpszNoteText = body.c_str();
>
>>    MapiMessage.nRecipCount = 0;
>>    MapiMessage.lpRecips = NULL;        // How to put Edit2->Text on
> lpRecips
>> ???
>
> Had you read the documentation, you would see that the lpRecips member is 
> an
> array of MapiRecipDesc structures.  So, to specify a single recipient, you
> simply declare an instance of the MapiRecipDesc structure, fill it in as
> needed, and then assign its memory pointer to the lpRecips member, ie:
>
>    AnsiString addr = "SMTP:" + Edit2->Text;
>
>    MapiRecipDesc recip = {0};
>    recip.ulRecipClass = MAPI_TO;
>    recip.lpszAddress = addr.c_str();
>
>    MapiMessage.nRecipCount = 1;
>    MapiMessage.lpRecips = &recip;
>
>>    MapiMessage.nFileCount = NULL;
>>    MapiMessage.lpFiles = NULL;          // How to put Edit1->Text on
> lpFiles
>> ???
>
> The same applies for files as well, except with the MapiFileDesc structure
> instead:
>
>    AnsiString path = Edit1->Text;
>    AnsiString filename = ExtractFileName(path);
>
>    MapiFileDesc file = {0};
>    file.nPosition = 0xFFFFFFFF;
>    recip.lpszPathName = path.c_str();
>    recip.lpszFileName = filename.c_str();
>
>    MapiMessage.nFileCount = 1;
>    MapiMessage.lpFiles = &file;
>
>
> Gambit
>
> 
Re: How display MAPIMAIL
#966
Author: Remy Lebeau (TeamB)
Date: Thu, 02 Mar 2006 01:45
138 lines
5836 bytes
"RS" <rs.reloaded@wanadoo.fr> wrote in message
news:440602dc$1@newsgroups.borland.com...

> My goal is not to send directly, I want the MAPI window to modify
> subject and body, and click send button  to send the mail.

Then you must specify the MAPI_DIALOG flag.

> If I Put MAPI_DIALOG instead of 0 in pfnSendMail(), the MAPI
> windows does correctly appear, and the attachments does appear
> correctly, but I can't modify subject, and I can't click to the send
button.

Despite what the documentation says, you need to specify a parent HWND to
MAPILogon(), MapiSendMail(), and MAPILogoff().  Then the popup window will
not be read-only.  You can use the TApplication::Handle property for that.

Try this code:

    LPTSTR GetFileName(LPTSTR szPathName)
    {
        LPTSTR szFileName = szPathName;
        LPTSTR ptr = szPathName;

        if( NULL != ptr )
        {
            while( 0 != *ptr )
            {
                if( TEXT('\\') == *ptr )
                {
                    szFileName = ::CharNext(ptr);
                    ptr = szFileName;
                }
                else
                    ptr = ::CharNext(ptr);
            }

            if( 0 != *szFileName )
                return szFileName;
        }

        return szPathName;
    }

    void SendMapiMessage(HWND hWnd, LPTSTR SenderAddr, LPTSTR RecipAddr,
LPTSTR Subject, LPTSTR Body, LPTSTR *Files, ULONG FileCount)
    {
        HINSTANCE hDll = ::LoadLibrary(TEXT("MAPI32.DLL"));
        if( NULL != hDll )
        {
            LPMAPILOGON pfnLogon = (LPMAPILOGON) ::GetProcAddress(hDll,
TEXT("MAPILogon"));
            LPMAPILOGOFF pfnLogoff = (LPMAPILOGOFF) ::GetProcAddress(hDll,
TEXT("MAPILogoff"));
            LPMAPISENDMAIL pfnSendMail = (LPMAPISENDMAIL)
::GetProcAddress(hDll, TEXT("MAPISendMail"));

            if( (NULL != pfnLogon) && (NULL != pfnLogoff) && (NULL !=
pfnSendMail) )
            {
                MapiFileDesc *mapifiledesc = NULL;
                if( 0 != FileCount )
                {
                    mapifiledesc = (MapiFileDesc*)
malloc(sizeof(MapiFileDesc) * FileCount);
                    if( NULL != mapifiledesc )
                    {
                        for(ULONG u = 0; u < FileCount; ++u)
                        {
                            mapifiledesc[u].nPosition    = -1;
                            mapifiledesc[u].lpszPathName = Files[u];
                            mapifiledesc[u].lpszFileName =
GetFileName(Files[u]);
                        }
                    }
                }

                if( (0 == FileCount) || (NULL != mapifiledesc) )
                {
                    LHANDLE lHnd;
                    ULONG err = pfnLogon((ULONG) hWnd, NULL, NULL,
MAPI_LOGON_UI, 0, &lHnd);

                    if( SUCCESS_SUCCESS == err )
                    {
                        MapiRecipDesc rdOriginator = {0};
                        rdOriginator.ulRecipClass  = MAPI_ORIG;
                        rdOriginator.lpszAddress   = SenderAddr;

                        MapiRecipDesc rdRecipient = {0};
                        rdRecipient.ulRecipClass  = MAPI_TO;
                        rdRecipient.lpszAddress   = RecipAddr;

                        MapiMessage mapimsg  = {0};
                        mapimsg.lpszSubject  = Subject;
                        mapimsg.lpszNoteText = Body;
                        mapimsg.lpOriginator = &rdOriginator;
                        mapimsg.nRecipCount  = 1;
                        mapimsg.lpRecips     = &rdRecipient;
                        mapimsg.nFileCount   = FileCount;
                        mapimsg.lpFiles      = mapifiledesc;

                        err = pfnSendMail(lHnd, (ULONG) hWnd, &mapimsg,
MAPI_DIALOG, 0);

                        if( SUCCESS_SUCCESS != err )
                            _tprintf(TEXT("could not send mapi32 message,
ErrorCode: %u"), err);

                        err = pfnLogoff(lHnd, (ULONG) hWnd, 0, 0);
                        if( SUCCESS_SUCCESS != err )
                            _tprintf(TEXT("could not log out of mapi32,
ErrorCode: %u"), err);
                    }
                    else
                        _tprintf(TEXT("could not log in to mapi32,
ErrorCode: %u"), err);

                    if( mapifiledesc )
                        free(mapifiledesc);
                }
                else
                    _tprintf(TEXT("could not allocate memory for
attachments"));
            }
            else
                _tprintf(TEXT("could not load mapi32 functions"));

            FreeLibrary(hDll);
        }
        else
            _tprintf(TEXT("could not load mapi32.dll, ErrorCode: %u"),
GetLastError());
    }


Gambit
Re: How display MAPIMAIL
#969
Author: RS
Date: Thu, 02 Mar 2006 18:52
169 lines
6736 bytes
Many Thanks Remy,

But I Have problem, can you put the full source code for my situation ?

My problem  is : I don't know who I put your code !! before what ? after 
what ? to replace something ?  I don't know ...

 I'm sorry, I'm not a big professionnal of C++ !!! lol

I Have error :

1) [C++ Error] Unit1.cpp(411): E2108 Improper use of typedef 'LPTSTR'

 LPTSTR GetFileName(LPTSTR szPathName)


My first code is on a simple button click.

Do I have create void TForm1:GetFileName() ??? and void 
TForm1::SendMapiMessage()  ???


Thanks a lot, you are very very ... good !!!    You advanced to me 10 
years!!!



"Remy Lebeau (TeamB)" <no.spam@no.spam.com> a �crit dans le message de news: 
44064ed2$1@newsgroups.borland.com...
>
> "RS" <rs.reloaded@wanadoo.fr> wrote in message
> news:440602dc$1@newsgroups.borland.com...
>
>> My goal is not to send directly, I want the MAPI window to modify
>> subject and body, and click send button  to send the mail.
>
> Then you must specify the MAPI_DIALOG flag.
>
>> If I Put MAPI_DIALOG instead of 0 in pfnSendMail(), the MAPI
>> windows does correctly appear, and the attachments does appear
>> correctly, but I can't modify subject, and I can't click to the send
> button.
>
> Despite what the documentation says, you need to specify a parent HWND to
> MAPILogon(), MapiSendMail(), and MAPILogoff().  Then the popup window will
> not be read-only.  You can use the TApplication::Handle property for that.
>
> Try this code:
>
>    LPTSTR GetFileName(LPTSTR szPathName)
>    {
>        LPTSTR szFileName = szPathName;
>        LPTSTR ptr = szPathName;
>
>        if( NULL != ptr )
>        {
>            while( 0 != *ptr )
>            {
>                if( TEXT('\\') == *ptr )
>                {
>                    szFileName = ::CharNext(ptr);
>                    ptr = szFileName;
>                }
>                else
>                    ptr = ::CharNext(ptr);
>            }
>
>            if( 0 != *szFileName )
>                return szFileName;
>        }
>
>        return szPathName;
>    }
>
>    void SendMapiMessage(HWND hWnd, LPTSTR SenderAddr, LPTSTR RecipAddr,
> LPTSTR Subject, LPTSTR Body, LPTSTR *Files, ULONG FileCount)
>    {
>        HINSTANCE hDll = ::LoadLibrary(TEXT("MAPI32.DLL"));
>        if( NULL != hDll )
>        {
>            LPMAPILOGON pfnLogon = (LPMAPILOGON) ::GetProcAddress(hDll,
> TEXT("MAPILogon"));
>            LPMAPILOGOFF pfnLogoff = (LPMAPILOGOFF) ::GetProcAddress(hDll,
> TEXT("MAPILogoff"));
>            LPMAPISENDMAIL pfnSendMail = (LPMAPISENDMAIL)
> ::GetProcAddress(hDll, TEXT("MAPISendMail"));
>
>            if( (NULL != pfnLogon) && (NULL != pfnLogoff) && (NULL !=
> pfnSendMail) )
>            {
>                MapiFileDesc *mapifiledesc = NULL;
>                if( 0 != FileCount )
>                {
>                    mapifiledesc = (MapiFileDesc*)
> malloc(sizeof(MapiFileDesc) * FileCount);
>                    if( NULL != mapifiledesc )
>                    {
>                        for(ULONG u = 0; u < FileCount; ++u)
>                        {
>                            mapifiledesc[u].nPosition    = -1;
>                            mapifiledesc[u].lpszPathName = Files[u];
>                            mapifiledesc[u].lpszFileName =
> GetFileName(Files[u]);
>                        }
>                    }
>                }
>
>                if( (0 == FileCount) || (NULL != mapifiledesc) )
>                {
>                    LHANDLE lHnd;
>                    ULONG err = pfnLogon((ULONG) hWnd, NULL, NULL,
> MAPI_LOGON_UI, 0, &lHnd);
>
>                    if( SUCCESS_SUCCESS == err )
>                    {
>                        MapiRecipDesc rdOriginator = {0};
>                        rdOriginator.ulRecipClass  = MAPI_ORIG;
>                        rdOriginator.lpszAddress   = SenderAddr;
>
>                        MapiRecipDesc rdRecipient = {0};
>                        rdRecipient.ulRecipClass  = MAPI_TO;
>                        rdRecipient.lpszAddress   = RecipAddr;
>
>                        MapiMessage mapimsg  = {0};
>                        mapimsg.lpszSubject  = Subject;
>                        mapimsg.lpszNoteText = Body;
>                        mapimsg.lpOriginator = &rdOriginator;
>                        mapimsg.nRecipCount  = 1;
>                        mapimsg.lpRecips     = &rdRecipient;
>                        mapimsg.nFileCount   = FileCount;
>                        mapimsg.lpFiles      = mapifiledesc;
>
>                        err = pfnSendMail(lHnd, (ULONG) hWnd, &mapimsg,
> MAPI_DIALOG, 0);
>
>                        if( SUCCESS_SUCCESS != err )
>                            _tprintf(TEXT("could not send mapi32 message,
> ErrorCode: %u"), err);
>
>                        err = pfnLogoff(lHnd, (ULONG) hWnd, 0, 0);
>                        if( SUCCESS_SUCCESS != err )
>                            _tprintf(TEXT("could not log out of mapi32,
> ErrorCode: %u"), err);
>                    }
>                    else
>                        _tprintf(TEXT("could not log in to mapi32,
> ErrorCode: %u"), err);
>
>                    if( mapifiledesc )
>                        free(mapifiledesc);
>                }
>                else
>                    _tprintf(TEXT("could not allocate memory for
> attachments"));
>            }
>            else
>                _tprintf(TEXT("could not load mapi32 functions"));
>
>            FreeLibrary(hDll);
>        }
>        else
>            _tprintf(TEXT("could not load mapi32.dll, ErrorCode: %u"),
> GetLastError());
>    }
>
>
> Gambit
>
> 
Re: How display MAPIMAIL
#971
Author: Remy Lebeau (TeamB)
Date: Thu, 02 Mar 2006 21:49
248 lines
8742 bytes
"RS" <rs.reloaded@wanadoo.fr> wrote in message
news:44073e03$1@newsgroups.borland.com...

> But I Have problem

Please be more specific.

> can you put the full source code for my situation ?

The code I gave you is a direct copy-paste from the test project I wrote for
this discussion, which works fine when I run it as-is.

> I don't know who I put your code !!

You simply replace the code you showed earlier with the code I gave you.
What exactly is so hard about that?

> I Have error :

You probably put the code in the wrong place.  GetFileName() is a standalone
function.  It cannot be placed inside another function, which is what you
are likely doing.

> My first code is on a simple button click.

Here is the FULL code I used for testing:

    --- Unit1.h---


//--------------------------------------------------------------------------
-

    #ifndef MapiSendMailFormH
    #define MapiSendMailFormH

//--------------------------------------------------------------------------
-
    #include <Classes.hpp>
    #include <Controls.hpp>
    #include <StdCtrls.hpp>
    #include <Forms.hpp>

//--------------------------------------------------------------------------
-
    class TForm1 : public TForm
    {
    __published: // IDE-managed Components
        TButton *Button1;
        void __fastcall Button1Click(TObject *Sender);
    private: // User declarations
    public:  // User declarations
    __fastcall TForm1(TComponent* Owner);
    };

//--------------------------------------------------------------------------
-
    extern PACKAGE TForm1 *Form1;

//--------------------------------------------------------------------------
-
    #endif

//--------------------------------------------------------------------------
-


    --- Unit1.cpp ---

    #include <vcl.h>
    #pragma hdrstop

    #include "Unit1.h"
    #include <mapi.h>

//--------------------------------------------------------------------------
-
    #pragma package(smart_init)
    #pragma resource "*.dfm"
    TForm1 *Form1;

//--------------------------------------------------------------------------
-
    __fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
    {
    }

//--------------------------------------------------------------------------
-
    LPTSTR GetFileName(LPTSTR szPathName)
    {
        LPTSTR szFileName = szPathName;
        LPTSTR ptr = szPathName;

        if( NULL != ptr )
        {
            while( 0 != *ptr )
            {
                if( TEXT('\\') == *ptr )
                {
                    szFileName = CharNext(ptr);
                    ptr = szFileName;
                }
                else
                    ptr = CharNext(ptr);
            }

            if( 0 != *szFileName )
                return szFileName;
        }

        return szPathName;
    }

    void SendMapiMessage(HWND hWnd, LPTSTR SenderAddr, LPTSTR RecipAddr,
LPTSTR Subject, LPTSTR Body, LPTSTR *Files, ULONG FileCount)
    {
        TCHAR szMsg[64];

        HINSTANCE hDll = LoadLibrary(TEXT("MAPI32.DLL"));
        if( NULL != hDll )
        {
            LPMAPILOGON pfnLogon = (LPMAPILOGON) GetProcAddress(hDll,
TEXT("MAPILogon"));
            LPMAPILOGOFF pfnLogoff = (LPMAPILOGOFF) GetProcAddress(hDll,
TEXT("MAPILogoff"));
            LPMAPISENDMAIL pfnSendMail = (LPMAPISENDMAIL)
GetProcAddress(hDll, TEXT("MAPISendMail"));

            if( (NULL != pfnLogon) && (NULL != pfnLogoff) && (NULL !=
pfnSendMail) )
            {
                MapiFileDesc *mapifiledesc = NULL;
                if( 0 != FileCount )
                {
                    mapifiledesc = (MapiFileDesc*)
malloc(sizeof(MapiFileDesc) * FileCount);
                    if( NULL != mapifiledesc )
                    {
                        for(ULONG u = 0; u < FileCount; ++u)
                        {
                            mapifiledesc[u].nPosition    = -1;
                            mapifiledesc[u].lpszPathName = Files[u];
                            mapifiledesc[u].lpszFileName =
GetFileName(Files[u]);
                        }
                    }
                }

                if( (0 == FileCount) || (NULL != mapifiledesc) )
                {
                    LHANDLE lHnd;
                    ULONG err = pfnLogon((ULONG) hWnd, NULL, NULL,
MAPI_LOGON_UI, 0, &lHnd);

                    if( SUCCESS_SUCCESS == err )
                    {
                        MapiRecipDesc rdOriginator = {0};
                        rdOriginator.ulRecipClass  = MAPI_ORIG;
                        rdOriginator.lpszAddress   = SenderAddr;

                        MapiRecipDesc rdRecipient = {0};
                        rdRecipient.ulRecipClass  = MAPI_TO;
                        rdRecipient.lpszAddress   = RecipAddr;

                        MapiMessage mapimsg  = {0};
                        mapimsg.lpszSubject  = Subject;
                        mapimsg.lpszNoteText = Body;
                        mapimsg.lpOriginator = &rdOriginator;
                        mapimsg.nRecipCount  = 1;
                        mapimsg.lpRecips     = &rdRecipient;
                        mapimsg.nFileCount   = FileCount;
                        mapimsg.lpFiles      = mapifiledesc;

                        err = pfnSendMail(lHnd, (ULONG) hWnd, &mapimsg,
MAPI_DIALOG, 0);

                        if( SUCCESS_SUCCESS != err )
                        {
                            wsprintf(szMsg, TEXT("could not send mapi32
message, ErrorCode: %u"), err);
                            MessageBox(NULL, szMsg, TEXT("Error"), MB_OK);
                        }

                        err = pfnLogoff(lHnd, (ULONG) hWnd, 0, 0);
                        if( SUCCESS_SUCCESS != err )
                        {
                            wsprintf(szMsg, TEXT("could not log out of
mapi32, ErrorCode: %u"), err);
                            MessageBox(NULL, szMsg, TEXT("Error"), MB_OK);
                        }
                    }
                    else
                    {
                        wsprintf(szMsg, TEXT("could not log in to mapi32,
ErrorCode: %u"), err);
                        MessageBox(NULL, szMsg, TEXT("Error"), MB_OK);
                    }

                    if( mapifiledesc )
                        free(mapifiledesc);
                }
                else
                    MessageBox(NULL, TEXT("could not allocate memory for
attachments"), TEXT("Error"), MB_OK);
            }
            else
            {
                MessageBox(NULL, TEXT("could not load mapi32 functions"),
TEXT("Error"), MB_OK);
            }

            FreeLibrary(hDll);
        }
        else
        {
            wsprintf(szMsg, TEXT("could not load mapi32.dll, ErrorCode:
%u"), GetLastError());
            MessageBox(NULL, szMsg, TEXT("Error"), MB_OK);
        }
    }

//--------------------------------------------------------------------------
-
    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
        LPTSTR Files[2] = {
            TEXT("C:\\autoexec.bat"),
            TEXT("C:\\config.sys")
        };

        SendMapiMessage(
            Application->Handle,
            TEXT("me@myaddress.com"),
            TEXT("you@youraddress.com"),
            TEXT("Here is the Subject"),
            TEXT("Here is the Body Text"),
            Files,
            2);
    }

//--------------------------------------------------------------------------
-


Gambit
Re: How display MAPIMAIL
#978
Author: RS
Date: Fri, 03 Mar 2006 18:37
272 lines
9648 bytes
Remy (Gambit) : you are the king !!

It works perfectly with outlook express !!!

Thank you very very very ... (very x 1000) much !!!! lol

But this code doesn't run if Microsoft Outlook 2003 is default mapi software 
:
Could not send mapi 32 message : ErrorCode : 11

It works perfectly with Outlook express 6.

My config : Borland C++ Builder 6 ,  PC XP Pro SP2, Office 2003


Many many many thanks !!!


"Remy Lebeau (TeamB)" <no.spam@no.spam.com> a �crit dans le message de news: 
4407681b$1@newsgroups.borland.com...
>
> "RS" <rs.reloaded@wanadoo.fr> wrote in message
> news:44073e03$1@newsgroups.borland.com...
>
>> But I Have problem
>
> Please be more specific.
>
>> can you put the full source code for my situation ?
>
> The code I gave you is a direct copy-paste from the test project I wrote 
> for
> this discussion, which works fine when I run it as-is.
>
>> I don't know who I put your code !!
>
> You simply replace the code you showed earlier with the code I gave you.
> What exactly is so hard about that?
>
>> I Have error :
>
> You probably put the code in the wrong place.  GetFileName() is a 
> standalone
> function.  It cannot be placed inside another function, which is what you
> are likely doing.
>
>> My first code is on a simple button click.
>
> Here is the FULL code I used for testing:
>
>    --- Unit1.h---
>
>
> //--------------------------------------------------------------------------
> -
>
>    #ifndef MapiSendMailFormH
>    #define MapiSendMailFormH
>
> //--------------------------------------------------------------------------
> -
>    #include <Classes.hpp>
>    #include <Controls.hpp>
>    #include <StdCtrls.hpp>
>    #include <Forms.hpp>
>
> //--------------------------------------------------------------------------
> -
>    class TForm1 : public TForm
>    {
>    __published: // IDE-managed Components
>        TButton *Button1;
>        void __fastcall Button1Click(TObject *Sender);
>    private: // User declarations
>    public:  // User declarations
>    __fastcall TForm1(TComponent* Owner);
>    };
>
> //--------------------------------------------------------------------------
> -
>    extern PACKAGE TForm1 *Form1;
>
> //--------------------------------------------------------------------------
> -
>    #endif
>
> //--------------------------------------------------------------------------
> -
>
>
>    --- Unit1.cpp ---
>
>    #include <vcl.h>
>    #pragma hdrstop
>
>    #include "Unit1.h"
>    #include <mapi.h>
>
> //--------------------------------------------------------------------------
> -
>    #pragma package(smart_init)
>    #pragma resource "*.dfm"
>    TForm1 *Form1;
>
> //--------------------------------------------------------------------------
> -
>    __fastcall TForm1::TForm1(TComponent* Owner)
>        : TForm(Owner)
>    {
>    }
>
> //--------------------------------------------------------------------------
> -
>    LPTSTR GetFileName(LPTSTR szPathName)
>    {
>        LPTSTR szFileName = szPathName;
>        LPTSTR ptr = szPathName;
>
>        if( NULL != ptr )
>        {
>            while( 0 != *ptr )
>            {
>                if( TEXT('\\') == *ptr )
>                {
>                    szFileName = CharNext(ptr);
>                    ptr = szFileName;
>                }
>                else
>                    ptr = CharNext(ptr);
>            }
>
>            if( 0 != *szFileName )
>                return szFileName;
>        }
>
>        return szPathName;
>    }
>
>    void SendMapiMessage(HWND hWnd, LPTSTR SenderAddr, LPTSTR RecipAddr,
> LPTSTR Subject, LPTSTR Body, LPTSTR *Files, ULONG FileCount)
>    {
>        TCHAR szMsg[64];
>
>        HINSTANCE hDll = LoadLibrary(TEXT("MAPI32.DLL"));
>        if( NULL != hDll )
>        {
>            LPMAPILOGON pfnLogon = (LPMAPILOGON) GetProcAddress(hDll,
> TEXT("MAPILogon"));
>            LPMAPILOGOFF pfnLogoff = (LPMAPILOGOFF) GetProcAddress(hDll,
> TEXT("MAPILogoff"));
>            LPMAPISENDMAIL pfnSendMail = (LPMAPISENDMAIL)
> GetProcAddress(hDll, TEXT("MAPISendMail"));
>
>            if( (NULL != pfnLogon) && (NULL != pfnLogoff) && (NULL !=
> pfnSendMail) )
>            {
>                MapiFileDesc *mapifiledesc = NULL;
>                if( 0 != FileCount )
>                {
>                    mapifiledesc = (MapiFileDesc*)
> malloc(sizeof(MapiFileDesc) * FileCount);
>                    if( NULL != mapifiledesc )
>                    {
>                        for(ULONG u = 0; u < FileCount; ++u)
>                        {
>                            mapifiledesc[u].nPosition    = -1;
>                            mapifiledesc[u].lpszPathName = Files[u];
>                            mapifiledesc[u].lpszFileName =
> GetFileName(Files[u]);
>                        }
>                    }
>                }
>
>                if( (0 == FileCount) || (NULL != mapifiledesc) )
>                {
>                    LHANDLE lHnd;
>                    ULONG err = pfnLogon((ULONG) hWnd, NULL, NULL,
> MAPI_LOGON_UI, 0, &lHnd);
>
>                    if( SUCCESS_SUCCESS == err )
>                    {
>                        MapiRecipDesc rdOriginator = {0};
>                        rdOriginator.ulRecipClass  = MAPI_ORIG;
>                        rdOriginator.lpszAddress   = SenderAddr;
>
>                        MapiRecipDesc rdRecipient = {0};
>                        rdRecipient.ulRecipClass  = MAPI_TO;
>                        rdRecipient.lpszAddress   = RecipAddr;
>
>                        MapiMessage mapimsg  = {0};
>                        mapimsg.lpszSubject  = Subject;
>                        mapimsg.lpszNoteText = Body;
>                        mapimsg.lpOriginator = &rdOriginator;
>                        mapimsg.nRecipCount  = 1;
>                        mapimsg.lpRecips     = &rdRecipient;
>                        mapimsg.nFileCount   = FileCount;
>                        mapimsg.lpFiles      = mapifiledesc;
>
>                        err = pfnSendMail(lHnd, (ULONG) hWnd, &mapimsg,
> MAPI_DIALOG, 0);
>
>                        if( SUCCESS_SUCCESS != err )
>                        {
>                            wsprintf(szMsg, TEXT("could not send mapi32
> message, ErrorCode: %u"), err);
>                            MessageBox(NULL, szMsg, TEXT("Error"), MB_OK);
>                        }
>
>                        err = pfnLogoff(lHnd, (ULONG) hWnd, 0, 0);
>                        if( SUCCESS_SUCCESS != err )
>                        {
>                            wsprintf(szMsg, TEXT("could not log out of
> mapi32, ErrorCode: %u"), err);
>                            MessageBox(NULL, szMsg, TEXT("Error"), MB_OK);
>                        }
>                    }
>                    else
>                    {
>                        wsprintf(szMsg, TEXT("could not log in to mapi32,
> ErrorCode: %u"), err);
>                        MessageBox(NULL, szMsg, TEXT("Error"), MB_OK);
>                    }
>
>                    if( mapifiledesc )
>                        free(mapifiledesc);
>                }
>                else
>                    MessageBox(NULL, TEXT("could not allocate memory for
> attachments"), TEXT("Error"), MB_OK);
>            }
>            else
>            {
>                MessageBox(NULL, TEXT("could not load mapi32 functions"),
> TEXT("Error"), MB_OK);
>            }
>
>            FreeLibrary(hDll);
>        }
>        else
>        {
>            wsprintf(szMsg, TEXT("could not load mapi32.dll, ErrorCode:
> %u"), GetLastError());
>            MessageBox(NULL, szMsg, TEXT("Error"), MB_OK);
>        }
>    }
>
> //--------------------------------------------------------------------------
> -
>    void __fastcall TForm1::Button1Click(TObject *Sender)
>    {
>        LPTSTR Files[2] = {
>            TEXT("C:\\autoexec.bat"),
>            TEXT("C:\\config.sys")
>        };
>
>        SendMapiMessage(
>            Application->Handle,
>            TEXT("me@myaddress.com"),
>            TEXT("you@youraddress.com"),
>            TEXT("Here is the Subject"),
>            TEXT("Here is the Body Text"),
>            Files,
>            2);
>    }
>
> //--------------------------------------------------------------------------
> -
>
>
> Gambit
>
> 
Re: How display MAPIMAIL
#979
Author: Remy Lebeau (TeamB)
Date: Fri, 03 Mar 2006 18:39
10 lines
1295 bytes
"RS" <rs.reloaded@wanadoo.fr> wrote in message
news:44088be9@newsgroups.borland.com...

> Could not send mapi 32 message : ErrorCode : 11

11 is MAPI_E_ATTACHMENT_NOT_FOUND.  Double-check your filenames.


Gambit
Re: How display MAPIMAIL
#981
Author: RS
Date: Fri, 03 Mar 2006 18:58
25 lines
1711 bytes
Thanks Remy,

My 2 files are quite present, since with outlook express, it does run 
correctly !
and my 2 files are c:\test.txt and c:\test.pdf ! why outlook does not run 
with this source code ?

Many thanks ;)


"Remy Lebeau (TeamB)" <no.spam@no.spam.com> a �crit dans le message de news: 
44088e3f$1@newsgroups.borland.com...
>
> "RS" <rs.reloaded@wanadoo.fr> wrote in message
> news:44088be9@newsgroups.borland.com...
>
>> Could not send mapi 32 message : ErrorCode : 11
>
> 11 is MAPI_E_ATTACHMENT_NOT_FOUND.  Double-check your filenames.
>
>
> Gambit
>
> 
Re: How display MAPIMAIL
#982
Author: Remy Lebeau (TeamB)
Date: Fri, 03 Mar 2006 20:33
12 lines
1622 bytes
"RS" <rs.reloaded@wanadoo.fr> wrote in message
news:4408910d@newsgroups.borland.com...

> why outlook does not run with this source code ?

I can't answer that.  I just tried it on Outlook 2000 and got the same
error.  Removing the attachments results in error 2 (MAPI_E_FAILURE) being
reported instead of 11.


Gambit
Re: How display MAPIMAIL
#983
Author: Remy Lebeau (TeamB)
Date: Fri, 03 Mar 2006 20:37
25 lines
2229 bytes
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:4408a7d4$1@newsgroups.borland.com...

> I can't answer that.  I just tried it on Outlook 2000 and got the same
> error.  Removing the attachments results in error 2 (MAPI_E_FAILURE) being
> reported instead of 11.

I can tell you, though, that I use similar code on other machines and it
works fine.  However, that code is logging into an actual mail profile
(specifying a non-empty string for the lpszProfileName parameter), whereas
the code in this discussion in not.  That might make a difference.  You can
look up the default profile in the Registry:

    Under Win9x/Me:
        HKCU\Software\Microsoft\Windows Messaging Subsystem\Profiles
        "DefaultProfile"="the name of the default profile"

    Under WinNT/2K/XP/2K3:
        HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging
Subsystem\Profiles
        "DefaultProfile"="the name of the default profile"


Gambit
Re: How display MAPIMAIL
#736
Author: RS
Date: Fri, 03 Mar 2006 20:47
27 lines
1984 bytes
Thanks Remy,

It's wonderful that it runs with Outlook Express, I search why outlook 
doesn't, and I'll be back ... lol

Thanks a lot Remy,  I fall almost in love with you ... lol  ( joke of course 
! )

Very Happy Week-end. In Paris (France), it's 21h45 and I'm tired !


"Remy Lebeau (TeamB)" <no.spam@no.spam.com> a �crit dans le message de news: 
4408a7d4$1@newsgroups.borland.com...
>
> "RS" <rs.reloaded@wanadoo.fr> wrote in message
> news:4408910d@newsgroups.borland.com...
>
>> why outlook does not run with this source code ?
>
> I can't answer that.  I just tried it on Outlook 2000 and got the same
> error.  Removing the attachments results in error 2 (MAPI_E_FAILURE) being
> reported instead of 11.
>
>
> Gambit
>
> 
Re: How display MAPIMAIL
#737
Author: RS
Date: Fri, 03 Mar 2006 20:53
111 lines
5305 bytes
Hey Hey Hey !!!

I'm finding this following source code, and it works with outlook 2003 !!!

I'm finally 2 sources codes that works with the 2 softwares OE and Ms 
Outlook.

I want to identify which software is the mapi default program, how can I 
find this ?

//-------------------------------------------------------------
 LPMAPISENDMAIL pfnSendMail;
   MapiRecipDesc  rdOriginator;
   MapiRecipDesc  rdRecipient[1];
   LPMAPILOGOFF   pfnLogoff;
   LPMAPILOGON    pfnLogon;
   MapiMessage    mapimsg;
   HINSTANCE      hDll;
   LHANDLE        lHnd;
   MapiFileDesc   mapifiledesc[2];

   if(NULL == (hDll = LoadLibrary(TEXT("MAPI32.DLL"))))
   {
       _tprintf(TEXT("could not load mapi32.dll, ErrorCode: %u"), 
GetLastError());
   }
   pfnLogon    = (LPMAPILOGON)GetProcAddress(hDll, "MAPILogon");
   pfnLogoff   = (LPMAPILOGOFF)GetProcAddress(hDll, "MAPILogoff");
   pfnSendMail = (LPMAPISENDMAIL)GetProcAddress(hDll, "MAPISendMail");

   pfnLogon(0, NULL, NULL, 0, 0, &lHnd);

   mapimsg.ulReserved   = 0;
   mapimsg.lpszSubject  = "This is the Subject";
   mapimsg.lpszNoteText = "This is the Body Message";
   mapimsg.lpszMessageType    = NULL;
   mapimsg.lpszDateReceived   = NULL;
   mapimsg.lpszConversationID = NULL;
   mapimsg.flFlags      = MAPI_UNREAD;

   mapimsg.lpOriginator = &rdOriginator;
   mapimsg.nRecipCount  = NUM_ELEMENTS(rdRecipient);
   mapimsg.lpRecips     = rdRecipient;
   mapimsg.nFileCount   = 2;
   mapimsg.lpFiles      = &mapifiledesc[0];

   rdOriginator.ulReserved   = 0;
   rdOriginator.ulRecipClass = MAPI_ORIG;
   rdOriginator.lpszName     = "rdOriginator";
   rdOriginator.lpszAddress  = "adresse@expediteur.com"; // Expediteur
   rdOriginator.ulEIDSize    = 0;
   rdOriginator.lpEntryID    = NULL;

   rdRecipient[0].ulReserved   = 0;
   rdRecipient[0].ulRecipClass = MAPI_TO;
   rdRecipient[0].lpszName     = "Name";
   rdRecipient[0].lpszAddress  = "adresse@destinataire.com";   // 
Destinataire
   rdRecipient[0].ulEIDSize    = 0;
   rdRecipient[0].lpEntryID    = NULL;

   mapifiledesc[0].ulReserved   = 0;
   mapifiledesc[0].flFlags      = 0;
   mapifiledesc[0].nPosition    = -1;
   mapifiledesc[0].lpszPathName = "C:\\test.txt";
   mapifiledesc[0].lpszFileName = "test.txt";
   mapifiledesc[0].lpFileType   = 0;

   mapifiledesc[1].ulReserved   = 0;
   mapifiledesc[1].flFlags      = 0;
   mapifiledesc[1].nPosition    = -1;
   mapifiledesc[1].lpszPathName = "C:\\test.pdf";
   mapifiledesc[1].lpszFileName = "test.pdf";
   mapifiledesc[1].lpFileType   = 0;
   pfnSendMail(lHnd,0, &mapimsg,MAPI_DIALOG,0);
   pfnLogoff(lHnd, 0, 0, 0);
   FreeLibrary(hDll);
//------------------------------------------------------------------------------------


"Remy Lebeau (TeamB)" <no.spam@no.spam.com> a �crit dans le message de news: 
4408a934@newsgroups.borland.com...
>
> "Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
> news:4408a7d4$1@newsgroups.borland.com...
>
>> I can't answer that.  I just tried it on Outlook 2000 and got the same
>> error.  Removing the attachments results in error 2 (MAPI_E_FAILURE) 
>> being
>> reported instead of 11.
>
> I can tell you, though, that I use similar code on other machines and it
> works fine.  However, that code is logging into an actual mail profile
> (specifying a non-empty string for the lpszProfileName parameter), whereas
> the code in this discussion in not.  That might make a difference.  You 
> can
> look up the default profile in the Registry:
>
>    Under Win9x/Me:
>        HKCU\Software\Microsoft\Windows Messaging Subsystem\Profiles
>        "DefaultProfile"="the name of the default profile"
>
>    Under WinNT/2K/XP/2K3:
>        HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging
> Subsystem\Profiles
>        "DefaultProfile"="the name of the default profile"
>
>
> Gambit
>
> 
Re: How display MAPIMAIL
#738
Author: RS
Date: Fri, 03 Mar 2006 20:57
121 lines
5688 bytes
My friend has the same problem with Visual Basic langage, he must have 2 
programs : One for OE and one for Ms Outlook.


"RS" <rs.reloaded@wanadoo.fr> a �crit dans le message de news: 
4408ac02@newsgroups.borland.com...
> Hey Hey Hey !!!
>
> I'm finding this following source code, and it works with outlook 2003 !!!
>
> I'm finally 2 sources codes that works with the 2 softwares OE and Ms 
> Outlook.
>
> I want to identify which software is the mapi default program, how can I 
> find this ?
>
> //-------------------------------------------------------------
> LPMAPISENDMAIL pfnSendMail;
>   MapiRecipDesc  rdOriginator;
>   MapiRecipDesc  rdRecipient[1];
>   LPMAPILOGOFF   pfnLogoff;
>   LPMAPILOGON    pfnLogon;
>   MapiMessage    mapimsg;
>   HINSTANCE      hDll;
>   LHANDLE        lHnd;
>   MapiFileDesc   mapifiledesc[2];
>
>   if(NULL == (hDll = LoadLibrary(TEXT("MAPI32.DLL"))))
>   {
>       _tprintf(TEXT("could not load mapi32.dll, ErrorCode: %u"), 
> GetLastError());
>   }
>   pfnLogon    = (LPMAPILOGON)GetProcAddress(hDll, "MAPILogon");
>   pfnLogoff   = (LPMAPILOGOFF)GetProcAddress(hDll, "MAPILogoff");
>   pfnSendMail = (LPMAPISENDMAIL)GetProcAddress(hDll, "MAPISendMail");
>
>   pfnLogon(0, NULL, NULL, 0, 0, &lHnd);
>
>   mapimsg.ulReserved   = 0;
>   mapimsg.lpszSubject  = "This is the Subject";
>   mapimsg.lpszNoteText = "This is the Body Message";
>   mapimsg.lpszMessageType    = NULL;
>   mapimsg.lpszDateReceived   = NULL;
>   mapimsg.lpszConversationID = NULL;
>   mapimsg.flFlags      = MAPI_UNREAD;
>
>   mapimsg.lpOriginator = &rdOriginator;
>   mapimsg.nRecipCount  = NUM_ELEMENTS(rdRecipient);
>   mapimsg.lpRecips     = rdRecipient;
>   mapimsg.nFileCount   = 2;
>   mapimsg.lpFiles      = &mapifiledesc[0];
>
>   rdOriginator.ulReserved   = 0;
>   rdOriginator.ulRecipClass = MAPI_ORIG;
>   rdOriginator.lpszName     = "rdOriginator";
>   rdOriginator.lpszAddress  = "adresse@expediteur.com"; // Expediteur
>   rdOriginator.ulEIDSize    = 0;
>   rdOriginator.lpEntryID    = NULL;
>
>   rdRecipient[0].ulReserved   = 0;
>   rdRecipient[0].ulRecipClass = MAPI_TO;
>   rdRecipient[0].lpszName     = "Name";
>   rdRecipient[0].lpszAddress  = "adresse@destinataire.com";   // 
> Destinataire
>   rdRecipient[0].ulEIDSize    = 0;
>   rdRecipient[0].lpEntryID    = NULL;
>
>   mapifiledesc[0].ulReserved   = 0;
>   mapifiledesc[0].flFlags      = 0;
>   mapifiledesc[0].nPosition    = -1;
>   mapifiledesc[0].lpszPathName = "C:\\test.txt";
>   mapifiledesc[0].lpszFileName = "test.txt";
>   mapifiledesc[0].lpFileType   = 0;
>
>   mapifiledesc[1].ulReserved   = 0;
>   mapifiledesc[1].flFlags      = 0;
>   mapifiledesc[1].nPosition    = -1;
>   mapifiledesc[1].lpszPathName = "C:\\test.pdf";
>   mapifiledesc[1].lpszFileName = "test.pdf";
>   mapifiledesc[1].lpFileType   = 0;
>   pfnSendMail(lHnd,0, &mapimsg,MAPI_DIALOG,0);
>   pfnLogoff(lHnd, 0, 0, 0);
>   FreeLibrary(hDll);
> //------------------------------------------------------------------------------------
>
>
> "Remy Lebeau (TeamB)" <no.spam@no.spam.com> a �crit dans le message de 
> news: 4408a934@newsgroups.borland.com...
>>
>> "Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
>> news:4408a7d4$1@newsgroups.borland.com...
>>
>>> I can't answer that.  I just tried it on Outlook 2000 and got the same
>>> error.  Removing the attachments results in error 2 (MAPI_E_FAILURE) 
>>> being
>>> reported instead of 11.
>>
>> I can tell you, though, that I use similar code on other machines and it
>> works fine.  However, that code is logging into an actual mail profile
>> (specifying a non-empty string for the lpszProfileName parameter), 
>> whereas
>> the code in this discussion in not.  That might make a difference.  You 
>> can
>> look up the default profile in the Registry:
>>
>>    Under Win9x/Me:
>>        HKCU\Software\Microsoft\Windows Messaging Subsystem\Profiles
>>        "DefaultProfile"="the name of the default profile"
>>
>>    Under WinNT/2K/XP/2K3:
>>        HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows 
>> Messaging
>> Subsystem\Profiles
>>        "DefaultProfile"="the name of the default profile"
>>
>>
>> Gambit
>>
>>
>
> 
Re: How display MAPIMAIL
#739
Author: RS
Date: Fri, 03 Mar 2006 21:20
150 lines
6491 bytes
Ok, no problem, i'm finding !!!

This registry key changes according to default mapi program :

HKEY_CLASSES_ROOT\mailto\shell\open\command

for MS Outlook :
"C:\PROGRA~1\MICROS~2\OFFICE11\OUTLOOK.EXE" -c IPM.Note /m "%1"

"Office11" is Office 2003, if you have office 2000 ("office")  or Office XP 
("office10")

for OE :
"%ProgramFiles%\Outlook Express\msimn.exe" /mailurl:%1

I can integrate a code which will read the registry and will launch the 
adequate source code !!

I'm a genius !!! (joke)  no ! no ! no ! i'm not a genius, the best is ... 
Remy of course !!!  lol

Many thanks, I think of being able me to leave there with all that


"RS" <rs.reloaded@wanadoo.fr> a �crit dans le message de news: 
4408acfe$1@newsgroups.borland.com...
> My friend has the same problem with Visual Basic langage, he must have 2 
> programs : One for OE and one for Ms Outlook.
>
>
> "RS" <rs.reloaded@wanadoo.fr> a �crit dans le message de news: 
> 4408ac02@newsgroups.borland.com...
>> Hey Hey Hey !!!
>>
>> I'm finding this following source code, and it works with outlook 2003 
>> !!!
>>
>> I'm finally 2 sources codes that works with the 2 softwares OE and Ms 
>> Outlook.
>>
>> I want to identify which software is the mapi default program, how can I 
>> find this ?
>>
>> //-------------------------------------------------------------
>> LPMAPISENDMAIL pfnSendMail;
>>   MapiRecipDesc  rdOriginator;
>>   MapiRecipDesc  rdRecipient[1];
>>   LPMAPILOGOFF   pfnLogoff;
>>   LPMAPILOGON    pfnLogon;
>>   MapiMessage    mapimsg;
>>   HINSTANCE      hDll;
>>   LHANDLE        lHnd;
>>   MapiFileDesc   mapifiledesc[2];
>>
>>   if(NULL == (hDll = LoadLibrary(TEXT("MAPI32.DLL"))))
>>   {
>>       _tprintf(TEXT("could not load mapi32.dll, ErrorCode: %u"), 
>> GetLastError());
>>   }
>>   pfnLogon    = (LPMAPILOGON)GetProcAddress(hDll, "MAPILogon");
>>   pfnLogoff   = (LPMAPILOGOFF)GetProcAddress(hDll, "MAPILogoff");
>>   pfnSendMail = (LPMAPISENDMAIL)GetProcAddress(hDll, "MAPISendMail");
>>
>>   pfnLogon(0, NULL, NULL, 0, 0, &lHnd);
>>
>>   mapimsg.ulReserved   = 0;
>>   mapimsg.lpszSubject  = "This is the Subject";
>>   mapimsg.lpszNoteText = "This is the Body Message";
>>   mapimsg.lpszMessageType    = NULL;
>>   mapimsg.lpszDateReceived   = NULL;
>>   mapimsg.lpszConversationID = NULL;
>>   mapimsg.flFlags      = MAPI_UNREAD;
>>
>>   mapimsg.lpOriginator = &rdOriginator;
>>   mapimsg.nRecipCount  = NUM_ELEMENTS(rdRecipient);
>>   mapimsg.lpRecips     = rdRecipient;
>>   mapimsg.nFileCount   = 2;
>>   mapimsg.lpFiles      = &mapifiledesc[0];
>>
>>   rdOriginator.ulReserved   = 0;
>>   rdOriginator.ulRecipClass = MAPI_ORIG;
>>   rdOriginator.lpszName     = "rdOriginator";
>>   rdOriginator.lpszAddress  = "adresse@expediteur.com"; // Expediteur
>>   rdOriginator.ulEIDSize    = 0;
>>   rdOriginator.lpEntryID    = NULL;
>>
>>   rdRecipient[0].ulReserved   = 0;
>>   rdRecipient[0].ulRecipClass = MAPI_TO;
>>   rdRecipient[0].lpszName     = "Name";
>>   rdRecipient[0].lpszAddress  = "adresse@destinataire.com";   // 
>> Destinataire
>>   rdRecipient[0].ulEIDSize    = 0;
>>   rdRecipient[0].lpEntryID    = NULL;
>>
>>   mapifiledesc[0].ulReserved   = 0;
>>   mapifiledesc[0].flFlags      = 0;
>>   mapifiledesc[0].nPosition    = -1;
>>   mapifiledesc[0].lpszPathName = "C:\\test.txt";
>>   mapifiledesc[0].lpszFileName = "test.txt";
>>   mapifiledesc[0].lpFileType   = 0;
>>
>>   mapifiledesc[1].ulReserved   = 0;
>>   mapifiledesc[1].flFlags      = 0;
>>   mapifiledesc[1].nPosition    = -1;
>>   mapifiledesc[1].lpszPathName = "C:\\test.pdf";
>>   mapifiledesc[1].lpszFileName = "test.pdf";
>>   mapifiledesc[1].lpFileType   = 0;
>>   pfnSendMail(lHnd,0, &mapimsg,MAPI_DIALOG,0);
>>   pfnLogoff(lHnd, 0, 0, 0);
>>   FreeLibrary(hDll);
>> //------------------------------------------------------------------------------------
>>
>>
>> "Remy Lebeau (TeamB)" <no.spam@no.spam.com> a �crit dans le message de 
>> news: 4408a934@newsgroups.borland.com...
>>>
>>> "Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
>>> news:4408a7d4$1@newsgroups.borland.com...
>>>
>>>> I can't answer that.  I just tried it on Outlook 2000 and got the same
>>>> error.  Removing the attachments results in error 2 (MAPI_E_FAILURE) 
>>>> being
>>>> reported instead of 11.
>>>
>>> I can tell you, though, that I use similar code on other machines and it
>>> works fine.  However, that code is logging into an actual mail profile
>>> (specifying a non-empty string for the lpszProfileName parameter), 
>>> whereas
>>> the code in this discussion in not.  That might make a difference.  You 
>>> can
>>> look up the default profile in the Registry:
>>>
>>>    Under Win9x/Me:
>>>        HKCU\Software\Microsoft\Windows Messaging Subsystem\Profiles
>>>        "DefaultProfile"="the name of the default profile"
>>>
>>>    Under WinNT/2K/XP/2K3:
>>>        HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows 
>>> Messaging
>>> Subsystem\Profiles
>>>        "DefaultProfile"="the name of the default profile"
>>>
>>>
>>> Gambit
>>>
>>>
>>
>>
>
> 
Re: How display MAPIMAIL
#740
Author: Remy Lebeau (TeamB)
Date: Sat, 04 Mar 2006 01:53
31 lines
2439 bytes
"RS" <rs.reloaded@wanadoo.fr> wrote in message
news:4408b243@newsgroups.borland.com...

> This registry key changes according to default mapi program :

That is not the correct place to look for MAPI settings.  The MAILTO
protocol is handled independantly of MAPI.  You should be looking in the
following Registry key instead:

    HKEY_LOCAL_MACHINE\Software\Clients\Mail

Each MAPI program has its own sub-key.  The (Default) value for the above
key specifies the default MAPI program.

The following Registry key specifies which mail program is used by other
applications that use MAPI, where each Value is either the name of the
sub-key above, or an empty for the default program.

    HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Messaging
Subsystem\MSMapiApps

> I can integrate a code which will read the registry and will launch
> the adequate source code !!

Why, though?  The whole point of using a standardized API is so that you
don't have to know anything about the specific program that the API accesses
internally.


Gambit
Re: How display MAPIMAIL
#741
Author: Remy Lebeau (TeamB)
Date: Sat, 04 Mar 2006 01:55
16 lines
1708 bytes
"RS" <rs.reloaded@wanadoo.fr> wrote in message
news:4408ac02@newsgroups.borland.com...

> I'm finding this following source code, and it works with outlook 2003 !!!

That is the EXACTLY same (buggy) code that you were using last week.

> I want to identify which software is the mapi default program,
> how can I find this ?

There isn't any direct way to do that.  You will have to look it up manually
in the Registry.


Gambit
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads