PDA

Ver la Versión Completa : Enviar email usando OUTLOOK 2003 - 2ª Parte


itsi
19-10-2007, 12:36:25
Buenos días a tod@s.

Despues de leer el hilo de (Enviar email usando OUTLOOK 2003), me funciona, pero tengo unas cuantas preguntas...... Os explico previamente lo que intento hacer.....

Genero un Informe con una ó varias empresas... (supongamos 5 empresas). Cuando envio los email mediante el OUTLOOK 2003.....

1 - solo reciben los ficheros adjuntos los que tengan OUTLOOK 2003.

2 - cuando termina de generar el archivo PDF y lo envio. El OUTLOOK 2003 me sale la siguiente pantalla.

3 - ¿Sabe alguien como que lo puedo hacer directamanete....?

4 - ¿Como puedo enviar para que lo puedan recibir todos?, dependiendo del Correo electronico que tengo el cliente.


procedure TForm.SpeedButton9Click(Sender: TObject);
var
Asunto,Texto,FicheroAEnviar, Direccion : string

begin
Asunto := 'Hola';
Texto := 'Adjunto le remito....';
FicheroAEnviar := 'c:\pdf1.pdf'; //Aqui cambia el nombre del archivo
Direccion := 'ppp@ppp.com'

SendMailMAPI(Asunto,Texto,FicheroAEnviar,'','',Direccion,Direccion);

end;

function TForm.SendMailMAPI(const Subject, Body, FileName, SenderName,
SenderEMail, RecepientName, RecepientEMail: String): Integer;
var
message: TMapiMessage;
lpSender, lpRecepient: TMapiRecipDesc;
FileAttach: TMapiFileDesc;
SM: TFNMapiSendMail;
MAPIModule: HModule;
begin

FillChar(message, SizeOf(message), 0);

with message do begin
if (Subject<>'') then
lpszSubject := PChar(Subject);
if (Body<>'') then
lpszNoteText := PChar(Body);
if (SenderEMail<>'') then begin
lpSender.ulRecipClass := MAPI_ORIG;
if (SenderName='') then
lpSender.lpszName := PChar(SenderEMail)
else
lpSender.lpszName := PChar(SenderName);
lpSender.lpszAddress := PChar('SMTP:'+SenderEMail);
lpSender.ulReserved := 0;
lpSender.ulEIDSize := 0;
lpSender.lpEntryID := nil;
lpOriginator := @lpSender;
end;
if (RecepientEMail<>'') then begin
lpRecepient.ulRecipClass := MAPI_TO;
if (RecepientName='') then
lpRecepient.lpszName := PChar(RecepientEMail)
else
lpRecepient.lpszName := PChar(RecepientName);
lpRecepient.lpszAddress := PChar('SMTP:'+RecepientEMail);
lpRecepient.ulReserved := 0;
lpRecepient.ulEIDSize := 0;
lpRecepient.lpEntryID := nil;
nRecipCount := 1;
lpRecips := @lpRecepient;
end
else
lpRecips := nil;
if (FileName='') then begin
nFileCount := 0;
lpFiles := nil;
end
else begin
FillChar(FileAttach, SizeOf(FileAttach), 0);
FileAttach.nPosition := Cardinal($FFFFFFFF);
FileAttach.lpszPathName := PChar(FileName);
nFileCount := 1;
lpFiles := @FileAttach;
end;
end;

MAPIModule := LoadLibrary(PChar(MAPIDLL));
if MAPIModule = 0 then begin
Result := -1;
end
else begin
try
@SM := GetProcAddress(MAPIModule, 'MAPISendMail');
if @SM <> nil then
Result := SM(0, 0, message, MAPI_LOGON_UI , 0)
else
Result := 1;
finally
FreeLibrary(MAPIModule);
end;
end;

if Result <> 0 then
showmessage('Error al enviar el Correo ('+IntToStr(Result)+').')
end;


Gracias de antemano.

Chris
20-10-2007, 01:10:33
En este hilo (http://www.clubdelphi.com/foros/showthread.php?t=33778) habíamos hablado del mismo tema. pasé semanas, buscando la solución, al final di con esta (http://www.clubdelphi.com/foros/showpost.php?p=235683&postcount=27).