Board index » cppbuilder » How to Activate default mail program on system with an attachment and some body text

How to Activate default mail program on system with an attachment and some body text


2005-05-04 08:51:57 PM
cppbuilder94
Hi,
i have an application with different export possibilities one should be by
mail
HWND lWindow;
ShellExecute( lWindow, NULL, "mailto: XXXX@XXXXX.COM ?Subject=For
translation&Body=Files to translate", NULL, NULL, 0);
this works fine but i dont get a file attached
is there an othere posibilitie
regardes
jvdn
p.s. also posted at builder.components.using
 
 

Re:How to Activate default mail program on system with an attachment and some body text

Hi,
i have an application with different export possibilities one should be by
mail
HWND lWindow;
ShellExecute( lWindow, NULL, "mailto: XXXX@XXXXX.COM ?Subject=For
translation&Body=Files to translate", NULL, NULL, 0);
this works fine but i dont get a file attached
is there an othere posibilitie
regardes
jvdn
p.s. also posted at builder.language.cpp
 

Re:How to Activate default mail program on system with an attachment and some body text

"Jochanan" < XXXX@XXXXX.COM >wrote:
Quote
Hi,

i have an application with different export possibilities one should be by
mail

HWND lWindow;
ShellExecute( lWindow, NULL, "mailto: XXXX@XXXXX.COM ?Subject=For
translation&Body=Files to translate", NULL, NULL, 0);

this works fine but i dont get a file attached

is there an othere posibilitie

regardes

jvdn

p.s. also posted at builder.language.cpp


Hi Jochanan,
Another method,
void __fastcall TFrmAcerca::LSendClick(TObject *Sender)
{
TMapiMessage MapiMsg;
TMapiRecipDesc MapiDsc[1];
MapiFileDesc *FileDesc;
Cardinal MError;
MapiDsc[0].ulReserved = 0;
MapiDsc[0].ulRecipClass = 1;
MapiDsc[0].lpszName = "Destination";
MapiDsc[0].lpszAddress = "SMTP: XXXX@XXXXX.COM ";
MapiDsc[0].ulEIDSize = 0;
MapiDsc[0].lpEntryID = NULL;
FileDesc = new MapiFileDesc();
FileDesc->ulReserved = 0;
FileDesc->flFlags = 0;
FileDesc->nPosition = 0;
FileDesc->lpszPathName = "C:\\Attachment.Txt";
FileDesc->lpszFileName = NULL;
FileDesc->lpFileType = NULL;
MapiMsg.ulReserved = 0;
MapiMsg.lpszSubject = "Subject String";
MapiMsg.lpszNoteText = "";
MapiMsg.lpszMessageType = NULL;
MapiMsg.lpszDateReceived = NULL;
MapiMsg.lpszConversationID = NULL;
MapiMsg.flFlags = 0;
MapiMsg.lpOriginator = NULL;
MapiMsg.nRecipCount = 1;
MapiMsg.lpRecips = &MapiDsc[0];
MapiMsg.nFileCount = 1;
MapiMsg.lpFiles = FileDesc;
MError = MapiSendMail( 0, 0, MapiMsg, MAPI_DIALOG | MAPI_LOGON_UI | MAPI_NEW_SESSION, 0 );
if ( MError )
Msg( "Cannot Send Mail!");
delete FileDesc;
}
HTH
Antonio
 

{smallsort}

Re:How to Activate default mail program on system with an attachment and some body text

"Antonio Felix" < XXXX@XXXXX.COM >schreef in bericht
Quote
Hi Jochanan,

Another method,

void __fastcall TFrmAcerca::LSendClick(TObject *Sender)
{

TMapiMessage MapiMsg;
where is this from BCB 6 Ent. not known??
Jochanan
 

Re:How to Activate default mail program on system with an attachment and some body text

Jochanan wrote:
Quote
p.s. also posted at builder.components.using
Well you shouldn't have done that really :)
Newsgroup guidelines ask that you post to the single most appropriate
section only. In this case it's not entirely clear what section is best
so .non-technical would have been my choice. Either that or .nativeapi
since it involves ShellExecute().
.language.cpp is for question relating to the C++ language, its
standard libraries and non-visual VCL classes so I don't think it
belongs here at all.
Follow-up set:.non-technical
--
Andrue Cope [TeamB]
[Bicester, Uk]
info.borland.com/newsgroups/guide.html
 

Re:How to Activate default mail program on system with an attachment and some body text

"Jochanan" < XXXX@XXXXX.COM >wrote:
Quote

"Antonio Felix" < XXXX@XXXXX.COM >schreef in bericht
news:4278ce74$ XXXX@XXXXX.COM ...
>Hi Jochanan,
>
>Another method,
>
>void __fastcall TFrmAcerca::LSendClick(TObject *Sender)
>{
>
>TMapiMessage MapiMsg;

where is this from BCB 6 Ent. not known??

Jochanan


Hi,
Include the MAPI.HPP header file ( at least it exists in BCB 5
Enterprise ).
It's just an encapsulation of the Win32 Sdk MapiMessage.
(See the Win Sdk Help File on MapiMessage )
HTH
Antonio
 

Re:How to Activate default mail program on system with an attachment and some body text

Jochanan wrote:
Quote
i have an application with different export possibilities one should be by
mail
Google for
simple mapi attachment
and
winapi email attachment
Also check out SMTP and the Indy component.
If you still have problems with it, post in the .nativeapi group.
Unless you decide to go with the Indy component, then it's
.internet.socket group
 

Re:How to Activate default mail program on system with an attachment and some body text

Are you sure about the code...I tried it, after including the mapi.hpp file, without success
Am I missing something? (I use BCB4 pro)
void __fastcall TForm1::Button38Click(TObject *Sender)
{
TMapiMessage MapiMsg;
TMapiRecipDesc MapiDsc[1];
MapiFileDesc *FileDesc;
Cardinal MError;
MapiDsc[0].ulReserved = 0;
MapiDsc[0].ulRecipClass = 1;
MapiDsc[0].lpszName = "Destination";
MapiDsc[0].lpszAddress = "SMTP: XXXX@XXXXX.COM ";
MapiDsc[0].ulEIDSize = 0;
MapiDsc[0].lpEntryID = NULL;
FileDesc = new MapiFileDesc();
FileDesc->ulReserved = 0;
FileDesc->flFlags = 0;
FileDesc->nPosition = 0;
FileDesc->lpszPathName = "C:\\Briefcase\\Note.rtf";
FileDesc->lpszFileName = NULL;
FileDesc->lpFileType = NULL;
MapiMsg.ulReserved = 0;
MapiMsg.lpszSubject = "Subject String";
MapiMsg.lpszNoteText = "";
MapiMsg.lpszMessageType = NULL;
MapiMsg.lpszDateReceived = NULL;
MapiMsg.lpszConversationID = NULL;
MapiMsg.flFlags = 0;
MapiMsg.lpOriginator = NULL;
MapiMsg.nRecipCount = 1;
MapiMsg.lpRecips = &MapiDsc[0];
MapiMsg.nFileCount = 1;
MapiMsg.lpFiles = FileDesc;
}
thanks
"Antonio Felix" < XXXX@XXXXX.COM >wrote:
Quote

"Jochanan" < XXXX@XXXXX.COM >wrote:
>
>"Antonio Felix" < XXXX@XXXXX.COM >schreef in bericht
>news:4278ce74$ XXXX@XXXXX.COM ...
>>Hi Jochanan,
>>
>>Another method,
>>
>>void __fastcall TFrmAcerca::LSendClick(TObject *Sender)
>>{
>>
>>TMapiMessage MapiMsg;
>
>where is this from BCB 6 Ent. not known??
>
>Jochanan
>
>
Hi,

Include the MAPI.HPP header file ( at least it exists in BCB 5
Enterprise ).
It's just an encapsulation of the Win32 Sdk MapiMessage.
(See the Win Sdk Help File on MapiMessage )

HTH
Antonio
 

Re:How to Activate default mail program on system with an attachment and some body text

"Freddy Mas" < XXXX@XXXXX.COM >wrote:
Quote

Are you sure about the code...I tried it, after including the mapi.hpp file, without success

Yes. Working Fine.
Do you get any errors ?
At CompileTime ?
At Run-Time ?
Br
Antonio
 

Re:How to Activate default mail program on system with an attachment and some body text

No error nothing...
When I click on the button, nothing happens
"Antonio Felix" < XXXX@XXXXX.COM >wrote:
Quote

"Freddy Mas" < XXXX@XXXXX.COM >wrote:
>
>Are you sure about the code...I tried it, after including the mapi.hpp file, without success
>

Yes. Working Fine.
Do you get any errors ?
At CompileTime ?
At Run-Time ?

Br
Antonio

 

Re:How to Activate default mail program on system with an attachment and some body text

"Freddy Mas" < XXXX@XXXXX.COM >wrote:
Quote

No error nothing...
When I click on the button, nothing happens

In your code i cannot see the MapiSendMail command ?
MError = MapiSendMail( 0, 0, MapiMsg,
MAPI_DIALOG |
MAPI_LOGON_UI |
MAPI_NEW_SESSION, 0 );
Are you using it!
HTH
Antonio
 

Re:How to Activate default mail program on system with an attachment and some body text

Thanks Antonio, I added the MapiSendMail command however when I
execute the code, I get prompted with User profile in which I
can selected "outlook default". I treid all the user profile
options and nothing happens...I don't know what's wrong
Freddy
"Antonio Felix" < XXXX@XXXXX.COM >wrote:
Quote

"Freddy Mas" < XXXX@XXXXX.COM >wrote:
>
>No error nothing...
>When I click on the button, nothing happens
>

In your code i cannot see the MapiSendMail command ?

MError = MapiSendMail( 0, 0, MapiMsg,
MAPI_DIALOG |
MAPI_LOGON_UI |
MAPI_NEW_SESSION, 0 );

Are you using it!

HTH
Antonio
 

Re:How to Activate default mail program on system with an attachment and some body text

"Freddy Mas" < XXXX@XXXXX.COM >wrote:
Quote

Thanks Antonio, I added the MapiSendMail command however when I
execute the code, I get prompted with User profile in which I
can selected "outlook default". I treid all the user profile
options and nothing happens...I don't know what's wrong

Freddy

Hi Freddy,
Try to leave the MAPI_LOGON_UI flag out of the Call
using just;
MError = MapiSendMail( 0, 0, MapiMsg,
MAPI_DIALOG |
MAPI_NEW_SESSION, 0 );
Take look at the Win32 Sdk Help file (MAPISendMail )for further
information on the flag meanings.
Cannot try it at the moment :-(
HTH
Antonio
 

Re:How to Activate default mail program on system with an attachment and some body text

"Freddy Mas" < XXXX@XXXXX.COM >wrote:
Quote

Thanks Antonio, I added the MapiSendMail command however when I
execute the code, I get prompted with User profile in which I
can selected "outlook default". I treid all the user profile
options and nothing happens...I don't know what's wrong

Freddy
In addition to the last message, do you have a proper email
address in MapiDsc[0].lpszAddress
Take a look at the posted code and see if anything in your
code is missing.
HTH
Antonio
 

Re:How to Activate default mail program on system with an attachment and some body text

Hi
i'm back
nice to see some of you continued on the point I left. I'll try the code
later next week.
regardes
jvdn
thanks for all replys
"Antonio Felix" < XXXX@XXXXX.COM >schreef in bericht
Quote

"Freddy Mas" < XXXX@XXXXX.COM >wrote:
>
>Thanks Antonio, I added the MapiSendMail command however when I
>execute the code, I get prompted with User profile in which I
>can selected "outlook default". I treid all the user profile
>options and nothing happens...I don't know what's wrong
>
>Freddy

In addition to the last message, do you have a proper email
address in MapiDsc[0].lpszAddress

Take a look at the posted code and see if anything in your
code is missing.

HTH
Antonio