Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Internet (https://www.clubdelphi.com/foros/forumdisplay.php?f=3)
-   -   Enviar email usando OUTLOOK 2003 - 2ª Parte (https://www.clubdelphi.com/foros/showthread.php?t=49351)

itsi 19-10-2007 12:36:25

Enviar email usando OUTLOOK 2003 - 2ª Parte
 
1 Archivos Adjunto(s)
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.

Código Delphi [-]
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 habíamos hablado del mismo tema. pasé semanas, buscando la solución, al final di con esta.


La franja horaria es GMT +2. Ahora son las 22:58:27.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi