Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros temas > Trucos
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Los mejores trucos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #21  
Antiguo 11-06-2008
Avatar de klaar
klaar klaar is offline
Registrado
 
Registrado: nov 2006
Posts: 9
Poder: 0
klaar Va por buen camino
al final no me queda claro como funciona. podrias poner el codigo entero final, con la configuracion de puertos...

gracias
1saludo
Responder Con Cita
  #22  
Antiguo 06-08-2008
Avatar de brakaman
[brakaman] brakaman is offline
Miembro Premium
 
Registrado: ago 2006
Ubicación: Castellon - España
Posts: 289
Poder: 18
brakaman Va por buen camino
Hola Khronos:

Funciona perfectamente tu primera version, tanto sin adjunto archivo como adjuntandolo.

Mil gracias.

Es la manera mas simple de enviar emial que he visto.
Esto demuestra la potencia de nuestro Delphi. A seguir resistiendo, esto tan simple con otro lenguaje seria imposible.

Enhorabuena.
Responder Con Cita
  #23  
Antiguo 19-08-2008
luisb luisb is offline
Miembro
 
Registrado: ago 2008
Posts: 10
Poder: 0
luisb Va por buen camino
Acá pongo otra forma... un poco mas compleja... yo la he usado varias veces... y me funciona independientemente del mailer que tenga configurado como por defecto...

function TForm1.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;
dwRet : Cardinal;
MAPI_Session : Cardinal;
WndList : Pointer;
begin
dwRet := MapiLogon(Handle, PChar(''), PChar(''), MAPI_LOGON_UI or MAPI_NEW_SESSION, 0, @MAPI_Session);

if (dwRet <> SUCCESS_SUCCESS) then
begin
MessageBox( Handle, PChar('Error al intentar mandar mensaje.'), PChar('Error'), MB_ICONERROR or MB_OK);
end
else
begin
FillChar(MapiMessage, SizeOf(MapiMessage), #0);
Attachments := nil;
FillChar(Receip, SizeOf(Receip), #0);

if Mail.Values['to'] <> '' then
begin
Receip.ulReserved := 0;
Receip.ulRecipClass := MAPI_TO;
Receip.lpszName := StrNew(PChar(Mail.Values['to']));
Receip.lpszAddress := StrNew(PChar('SMTP:' + Mail.Values['to']));
Receip.ulEIDSize := 0;
MapiMessage.nRecipCount := 1;
MapiMessage.lpRecips := @Receip;
end;

AttachCount := 0;

for i1 := 0 to MaxInt do
begin
if Mail.Values['attachment' + IntToStr(i1)] = '' then
break;
Inc(AttachCount);
end;

if AttachCount > 0 then
begin
GetMem(Attachments, SizeOf(TMapiFileDesc) * AttachCount);

for i1 := 0 to AttachCount - 1 do
begin
FileName := Mail.Values['attachment' + IntToStr(i1)];
Attachments[i1].ulReserved := 0;
Attachments[i1].flFlags := 0;
Attachments[i1].nPosition := ULONG($FFFFFFFF);
Attachments[i1].lpszPathName := StrNew(PChar(FileName));
Attachments[i1].lpszFileName := StrNew(PChar(ExtractFileName(FileName)));
Attachments[i1].lpFileType := nil;
end;
MapiMessage.nFileCount := AttachCount;
MapiMessage.lpFiles := @Attachments^;
end;

if Mail.Values['subject'] <> '' then MapiMessage.lpszSubject := StrNew(PChar(Mail.Values['subject']));
if Mail.Values['body'] <> '' then MapiMessage.lpszNoteText := StrNew(PChar(Mail.Values['body']));

WndList := DisableTaskWindows(0);
try
Result := MapiSendMail(MAPI_Session, Handle,
MapiMessage, MAPI_DIALOG, 0);
finally
EnableTaskWindows( WndList );
end;

for i1 := 0 to AttachCount - 1 do
begin
StrDispose(Attachments[i1].lpszPathName);
StrDispose(Attachments[i1].lpszFileName);
end;

if Assigned(MapiMessage.lpszSubject) then StrDispose(MapiMessage.lpszSubject);
if Assigned(MapiMessage.lpszNoteText) then StrDispose(MapiMessage.lpszNoteText);
if Assigned(Receip.lpszAddress) then StrDispose(Receip.lpszAddress);
if Assigned(Receip.lpszName) then StrDispose(Receip.lpszName);

MapiLogOff(MAPI_Session, Handle, 0, 0);
end;
end;
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 20:21:50.


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
Copyright 1996-2007 Club Delphi