🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.web
Article #963

Re: How display MAPIMAIL

#963
From: 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
Technical Details
Message-ID: <4404fe85$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4402040f@newsgroups.borland.com> <4404bbf5$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-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.web
References: <4402040f@newsgroups.borland.com> <4404bbf5$1@newsgroups.borland.com>
Subject: Re: How display MAPIMAIL
Date: Tue, 28 Feb 2006 17:54:02 -0800
Lines: 72
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <4404fe85$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1141177989 68.69.17.41 (28 Feb 2006 17:53:09 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail