Article View: borland.public.cppbuilder.internet.web
Article #969Re: How display MAPIMAIL
From: RS
Date: Thu, 02 Mar 2006 18:52
Date: Thu, 02 Mar 2006 18:52
169 lines
6736 bytes
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
>
>
Technical Details
Message-ID:
<44073e03$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<4402040f@newsgroups.borland.com> <4404bbf5$1@newsgroups.borland.com> <4404fe85$1@newsgroups.borland.com> <440602dc$1@newsgroups.borland.com> <44064ed2$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,b415d4e666b19fd4 X-Google-Attributes: gidfeeec,public X-Google-Language: ENGLISH,ASCII From: "RS" <rs.reloaded@wanadoo.fr> Newsgroups: borland.public.cppbuilder.internet.web References: <4402040f@newsgroups.borland.com> <4404bbf5$1@newsgroups.borland.com> <4404fe85$1@newsgroups.borland.com> <440602dc$1@newsgroups.borland.com> <44064ed2$1@newsgroups.borland.com> Subject: Re: How display MAPIMAIL Date: Thu, 2 Mar 2006 19:52:21 +0100 Lines: 171 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2670 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 83.196.161.97 Message-ID: <44073e03$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1141325315 83.196.161.97 (2 Mar 2006 10:48:35 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail