Recent

Author Topic: Send emails with attachments using LNET [SOLVED]  (Read 5539 times)

joaowiciuk

  • New Member
  • *
  • Posts: 10
Send emails with attachments using LNET [SOLVED]
« on: October 14, 2011, 01:15:14 am »
Hello everybody, I wonder how I can send emails with attachments using LNET (TLSMTPClientComponent and TLSSLSessionComponet). I tested the code below but it did not work:

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
var
  Stream: TMimeStream;
begin
  Stream := TMimeStream.Create;
  Stream.AddFileSection('C:\DOCUME~1\Usuario\Desktop\log.txt');
  Stream.Reset;
  if not SMTP.Connected then SMTP.Connect('smtp.live.com', 25);
  SMTP.StartTLS;
  if SMTP.HasFeature('AUTH LOGIN') then // use login if possible
    SMTP.AuthLogin('joaowiciuk@hotmail.com', '******')
  else if SMTP.HasFeature('AUTH PLAIN') then // fall back to plain if possible
    SMTP.AuthPlain('joaowiciuk@hotmail.com', '******');
  //SMTP.SendMail(EditFrom.Text, EditTo.Text, EditSubject.Text, FMimeStream); -> send the stream
  SMTP.SendMail('joaowiciuk@hotmail.com', 'joaowiciuk@hotmail.com', 'Teste', Stream); // send the stream
end;

when I click the button nothing happens and the mail does not reach to my inbox or junk folder.
« Last Edit: October 22, 2011, 11:18:43 pm by joaowiciuk »

nopain180

  • Newbie
  • Posts: 2
Re: Send emails with attachments using LNET
« Reply #1 on: October 21, 2011, 07:01:50 am »
According to smtphotmail.com, you can use ssl. Have you tried ssl? Port 587?

joaowiciuk

  • New Member
  • *
  • Posts: 10
Re: Send emails with attachments using LNET
« Reply #2 on: October 21, 2011, 05:34:23 pm »
Thanks dude, but I already discovered how solve my problem.

http://lazarus.freepascal.org/index.php/topic,14958.msg79811.html#msg79811

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Send emails with attachments using LNET
« Reply #3 on: October 21, 2011, 09:00:28 pm »
If you've already solved your problem, maybe a good idea to mark the thread subject as [SOLVED]....
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

nopain180

  • Newbie
  • Posts: 2
Re: Send emails with attachments using LNET
« Reply #4 on: October 22, 2011, 07:00:39 am »
Didn't see your other thread. Glad you got it straightened out.