Hola a todos.
Estoy utilizando una función que reproduzco más abajo para enviar el correo electrónico mediante MAPI y me funciona a la perfección.
El caso es que esta función me presenta la ventana de envío del correo con todos los campos llenos y debo pulsar el botón de "enviar" para que éste se realice.
Lo que yo quisiera es que el envío se realizara directamente sin que aparezca esta ventana, bueno, que el usuario no tenga que realizar ninguna acción y que la función realizara efectivamente el envío.
Gracias.
Código Delphi
[-]
function 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, Application.Handle, message, MAPI_DIALOG or MAPI_LOGON_UI, 0)
else
Result := 1;
finally
FreeLibrary(MAPIModule);
end;
end;
if Result <> 0 then
Mensaje('Error al enviar el Correo ('+IntToStr(Result)+').')
end;