E-mail no delphi6
galera. eu to no delphi6. estou tentando enviar um e-mail pelo smtp da palheta fastnet. mas meu delphi fala seguinte na hora do envio socket is not connected. como resolver isso, sendo que o smtp está conectado?
Anonymous
Curtidas 0
Respostas
Ajmsistemas
12/02/2003
Amigo... manda um email para mim que te mando os codigos fontes que tenho aki... já usei e deu certo..
falou...
Andeson de Jesus
:arrow: andeson.j@terra.com.br
estou aguardando...
falou...
Andeson de Jesus
:arrow: andeson.j@terra.com.br
estou aguardando...
GOSTEI 0
Dor_poa
12/02/2003
Usa o demo que acompanha o delphi....
GOSTEI 0
Anonymous
12/02/2003
Utiliza os componentes da guia Indy, são muito mais fáceis de utilizar e de configurar. qualquer dúvida é só me mandar um e-mail para que eu possa te ajudar melhor.
poetanoturno@hotmail.com
poetanoturno@hotmail.com
GOSTEI 0
Anonymous
12/02/2003
Aí pessoal, beleza?
Olha eu criei um programa só para enviar uns formularios via e-mail, mas quando rodo acontece o mesmo, eu acho que é o servidor ñ esta aceitando mais esse protocolo!
Tenta enviar de qualquer outro programa, usando o IG por exemplo!
Qual quer coisa entre em contato por e-mail ou icq.
Olha eu criei um programa só para enviar uns formularios via e-mail, mas quando rodo acontece o mesmo, eu acho que é o servidor ñ esta aceitando mais esse protocolo!
Tenta enviar de qualquer outro programa, usando o IG por exemplo!
Qual quer coisa entre em contato por e-mail ou icq.
GOSTEI 0
Anonymous
12/02/2003
Use a seguinte função para chamar a caixa postal padrão:
uses Mapi;
function 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 while trying to send email´),
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;
Exemplo de chamada:
procedure TForm1.Button1Click(Sender: TObject);
var
mail: TStringList;
begin
mail := TStringList.Create;
try
mail.values[´to´] := ´Receiver-Email@test.xyz´;
mail.values[´subject´] := ´Hello´;
mail.values[´body´] := ´blah´;
mail.values[´body´] := ´blah´;
mail.values[´attachment0´] := ´C:\Test.txt´;
// mail.values[´attachment1´]:=´C:\Test2.txt´;
sendEMail(Application.Handle, mail);
finally
mail.Free;
end;
end;
uses Mapi;
function 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 while trying to send email´),
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;
Exemplo de chamada:
procedure TForm1.Button1Click(Sender: TObject);
var
mail: TStringList;
begin
mail := TStringList.Create;
try
mail.values[´to´] := ´Receiver-Email@test.xyz´;
mail.values[´subject´] := ´Hello´;
mail.values[´body´] := ´blah´;
mail.values[´body´] := ´blah´;
mail.values[´attachment0´] := ´C:\Test.txt´;
// mail.values[´attachment1´]:=´C:\Test2.txt´;
sendEMail(Application.Handle, mail);
finally
mail.Free;
end;
end;
GOSTEI 0
Anonymous
12/02/2003
Tô precisando muito de mandar relatórios por e-mail, através do Delphi.
Será que você podia me mandar o que tem?
Desde já valeu!!!
E-mail: mateusassis@tjmg.gov.br
Será que você podia me mandar o que tem?
Desde já valeu!!!
E-mail: mateusassis@tjmg.gov.br
GOSTEI 0