![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
#1
|
|||
|
|||
|
Enviar Correo
Necesito con suma urgencia enviar correo con attach y que se abra mi cliente de correo antes de enviarlo, estube revisando en la seccion trucos y encontre "enviar correos en forma elegante", el cual no permite enviar con attach.
por favor si alguien a logrado modificar este truco, me puede indicar como. gracias ![]() |
|
#2
|
|||
|
|||
|
añade esta linea
if (filen > '') then header := header + '&attachment="' + filen+'"'; filen es un string más, que lo declaras junto a mailto,mailsubject etc... y donde haces MailTo := '[email protected]';, etc... haces filen := 'c:\s.txt'; a ver que tal PD:Copiate la lines,haz un copy paste de la linea, porque parecen comillas simples, y hay algunas comillas dobles saludos |
|
#3
|
|||
|
|||
|
Gracias, pero no funciona
|
|
#4
|
|||
|
|||
|
A mi me funciona.
ahora te pondre el código entero A ver que tal |
|
#5
|
|||
|
|||
|
Yo uso delphi 7 y winxp, outlook 2000.
Si copias todo el código que te puesto y lo añades a un unit nuevo, pones un boton y un memo y lo pruebas, a mi me funciona Código:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,shellapi;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
procedure RunDefaultMailer;
{ Public declarations }
end;
Const
EOL = '%0D%0A'; // end of line
Signature = EOL + EOL + 'Saludos desde París' + EOL + 'Carlos Conca';
var
Form1: TForm1;
filen,
MailTo,
MailSubject,
MailCC, // Carbon Copy
MailBCC, // Blind Carbon Copy
MailBody: String;
implementation
{$R *.dfm}
procedure TForm1.RunDefaultMailer;
var
header,
mail : String;
ShellResult : integer;
begin
if (MailTo ='') then begin // también funciona sin destinatario
ShowMessage('Falta el destinatario...');
Exit;
end;
header := 'mailto:' + MailTo;
if (MailSubject >'') then header := header + '?Subject=' + MailSubject;
if (MailCC >'') then header := header + '&cc=' + MailCC;
if (MailBCC >'') then header := header + '&bcc=' + MailBCC;
if (filen > '') then header := header + '&attachment="' + filen+'"';
mail := header + '&body=' + MailBody + Signature;
ShellResult := ShellExecute(Application.mainform.Handle,'open',PChar(mail), nil, nil, SW_MAXIMIZE);
//SHOWDEFAULT);
if (ShellResult <= 32) then ShowMessage('Error Num '+IntToStr(ShellResult)+' en ShellExecute.'+
#13+'Consulte la ayuda de Delphi.'+#13+'lenght(mail) ='+IntToStr(length(mail)));
end;
procedure TForm1.Button1Click(Sender: TObject);
var
n: Integer;
begin
filen := 'c:\r.txt';
MailTo := '[email protected]';
MailSubject := 'Cómo enviar un mail';
MailCC := '[email protected]';
MailBCC := '[email protected]';
MailBody := '';
if (Memo1.Lines.Count > 1) then begin
MailBody := MailBody + Memo1.Lines[0];
for n := 1 to Memo1.Lines.Count - 1 do
MailBody := MailBody + EOL + Memo1.Lines[n];
end;
RunDefaultMailer;
end;
end.
Saludos Última edición por Descendents fecha: 17-12-2003 a las 13:16:26. |
|
#6
|
|||
|
|||
|
Yo lo tengo exactamente igual pero no funciona.
Trabajo con delphi 6 y Outlook Express Saludos |
|
#7
|
|||
|
|||
|
ok el problema es outlook express.
Prueba esto Código:
procedure TForm1.Button1Click(Sender: TObject);
const
olMailItem = 0;
var
Outlook, MailItem: OLEVariant;
begin
try
Outlook := GetActiveOleObject('Outlook.Application');
except
Outlook := CreateOleObject('Outlook.Application');
end;
MailItem := Outlook.CreateItem(olMailItem);
MailItem.Recipients.Add('delphi at elists.org');
MailItem.Subject := 'your subject';
MailItem.Body := 'Visit: http://www.elists.org/mailman/listinfo/delphi';
MailItem.Attachments.Add('C:\autoexec.bat');
MailItem.Send;
Outlook := Unassigned;
end;
Uses Comobj Suerte, a vder si sirve de algo. Saludos |
|
#8
|
|||
|
|||
|
como ultimo si no te funciona prueba esto
Código:
procedure TForm1.Button1Click(Sender: TObject); var pCh: PChar; begin pCh :='mailto:[email protected]?subject=sujeto&body=cuerpo&file="c:\index.htm"'; ShellExecute(0, 'open', pCh, nil, nil, SW_SHOWNORMAL); end; Si esto no te sirve, y lo consigues, comunicalo al foro como. Yo no puedo probarlo, porque no tengo el express. Pero con outlook esto me funciona. Saludos |
![]() |
|
|
|