mhervais
asked on
How to launch the default mail program
Hi,
I would like to send an email using the default mail program (outlook express or whatever), and I would like to prewrite the reciver address, the subject and the message (or to predefine an attachment)
I am using D4.03
Who knows what to do ?
I would like to send an email using the default mail program (outlook express or whatever), and I would like to prewrite the reciver address, the subject and the message (or to predefine an attachment)
I am using D4.03
Who knows what to do ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Listening
ASKER
thanks for these answers. I will try them tomorrow and tell you
Regards, Marc
Regards, Marc
listen
ASKER
Points go to Epsylon whos proposal was fully working and preferred by my assistant who found it more easy to understand
Thanks to you two
Regards, Marc
Thanks to you two
Regards, Marc
ShellExecute(Form1.Handle,
A better way might be just to use MAPI:
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;
iCount : INTEGER;
FileName : STRING;
BEGIN
fillChar(MapiMessage, SizeOf(MapiMessage), #0);
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(PChar('SMTP:' + Mail.Values['to']));
Receip.ulEIDSize := 0;
MapiMessage.nRecipCount := 1;
MapiMessage.lpRecips := @Receip;
END;
AttachCount := 0;
FOR iCount := 0 TO MaxInt
DO
BEGIN
IF Mail.Values['attachment' + IntToStr(iCount)] = ''
THEN
BREAK;
AttachCount := AttachCount + 1;
END;
IF AttachCount > 0
THEN
BEGIN
GetMem(Attachments,SizeOf(
FOR iCount := 0 TO (AttachCount - 1)
DO
BEGIN
FileName := Mail.Values['attachment' + IntToStr(iCount)];
Attachments[iCount].ulRese
Attachments[iCount].flFlag
Attachments[iCount].nPosit
Attachments[iCount].lpszPa
Attachments[iCount].lpszFi
Attachments[iCount].lpFile
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
FOR iCount := 0 TO (AttachCount - 1)
DO
BEGIN
strDispose(Attachments[iCo
strDispose(Attachments[iCo
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'] := 'Bloke@Geeza.com';
mail.values['subject'] := 'A subject';
mail.values['body'] := 'Some body text (line 1)';
mail.values['body'] := 'Some more body text (line 2)';
mail.values['attachment0']
mail.values['attachment1']
sendEMail(Application.Hand
mail.Free;
END;
The Neil