Schmoekel
asked on
ShellExecute... to start my email-client...
Hello !
With my code here i can start my email-client with the parameters 'subject' and 'mailto'.:
//------------------------ ------
procedure TForm5.Button2Click(Sender : TObject);
var
s : String;
e : String;
begin
e := 'Ingo.Schmoekel@t-online.d e';
s := 'mailto:'+e+'?subject=Viel en Dank...!';
ShellExecute(hinstance,'op en',PChar( s),nil,nil ,SW_SHOWNO RMAL);
end;
//------------------------ --
Is it possible to send more parameters? ...I need 'Body or so' for the whole email-text and something for an attached file?!
Thank's a lot for a code-sample or even any tip!
Sincerly,
Ingo Schmökel
With my code here i can start my email-client with the parameters 'subject' and 'mailto'.:
//------------------------
procedure TForm5.Button2Click(Sender
var
s : String;
e : String;
begin
e := 'Ingo.Schmoekel@t-online.d
s := 'mailto:'+e+'?subject=Viel
ShellExecute(hinstance,'op
end;
//------------------------
Is it possible to send more parameters? ...I need 'Body or so' for the whole email-text and something for an attached file?!
Thank's a lot for a code-sample or even any tip!
Sincerly,
Ingo Schmökel
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
uses mapi;
function SendEMail(Handle :THandle;Mail :TStrings):Cardinal;
type
TAttachAccessArray = ARRAY [0..0] OF TMapiFileDesc;
PAttachAccessArray = ^TAttachAccessArray;
var
MapiMessage : TMapiMessage;
Receip : TMapiRecipDesc;
Attachments : PAttachAccessArray;
AttachCount : Integer;
i1 : Integer;
FileName : String;
begin
fillChar(MapiMessage,SizeO
Attachments:=nil;
fillChar(Receip,SizeOf(Rec
if Mail.Values['to'] <> ''
then
begin
Receip.ulReserved := 0;
Receip.ulRecipClass := MAPI_TO;
Receip.lpszName := StrNew(PChar(Mail.Values['
Receip.lpszAddress:=StrNew
Receip.ulEIDSize:=0;
MapiMessage.nRecipCount := 1;
MapiMessage.lpRecips := @Receip;
end;
AttachCount := 0;
for i1 := 0 to MaxInt
do
begin
if Mail.Values['attachment'+i
then
break;
inc(AttachCount);
end;
if AttachCount > 0
then
begin
GetMem(Attachments,SizeOf(
for i1 := 0 to AttachCount-1
do
begin
FileName := Mail.Values['attachment'+i
Attachments[i1].ulReserved
Attachments[i1].flFlags := 0;
Attachments[i1].nPosition := ULONG($FFFFFFFF);
Attachments[i1].lpszPathNa
Attachments[i1].lpszFileNa
)));
Attachments[i1].lpFileType
end;
MapiMessage.nFileCount := AttachCount;
MapiMessage.lpFiles := @Attachments^;
end;
if Mail.Values['subject'] <> ''
then
MapiMessage.lpszSubject := StrNew(PChar(Mail.Values['
if Mail.Values['body'] <> ''
then
MapiMessage.lpszNoteText
:= StrNew(PChar(Mail.Values['
Result := MapiSendMail(0, Handle, MapiMessage,MAPI_DIALOG*Or
or MAPI_LOGON_UI or MAPI_NEW_SESSION, 0);
for i1 := 0 to AttachCount-1
do
begin
strDispose(Attachments[i1]
strDispose(Attachments[i1]
end;
if assigned(MapiMessage.lpszS
then
strDispose(MapiMessage.lps
if assigned(MapiMessage.lpszN
then
strDispose(MapiMessage.lps
if assigned(Receip.lpszAddres
then
strDispose(Receip.lpszAddr
if assigned(Receip.lpszName)
then
strDispose(Receip.lpszName
end;
procedure TForm1.Button1Click(Sender
var
mail : TStringList
begin
mail := TStringList.Create;
mail.values['to']:='xyz@zz
mail.values['subject'] := 'no subject';
mail.values['body'] := 'no subject';
mail.values['body'] := 'no subject';
mail.values['attachment0']
mail.values['attachment1']
sendEMail(application.hand
mail.free;
end;
The Neil