Recent

Author Topic: Sending an email (using synapse)  (Read 2316 times)

KalElSPJ

  • Newbie
  • Posts: 1
Sending an email (using synapse)
« on: May 18, 2020, 08:27:21 pm »
I am trying to send an email from within my program, using synapse.

I found the example code on synapse's website, and the settings from google for the gmail address

I modified the source data only include "messages" on failing to login. From what I can gather it the problem is that the login fails. although when I manually use the password and username it does work... the only settings Im not putting on here is the from, return address username and password but replaced them, for security reasons.

Can you please tell me what I am doing wrong.....

Or give me a better example  (as simple as possible) for sending an email from a gmail address with an attachment.

The following is the code:
Type
  MyEmailType = Record
      Attachment : String;
      Address : String;
      FromAddress : String;
      Subject : String;
      Stmp : String;
      UserName : String;
      Password : String;
    end;

Var
 TmpMail : MyEmailType;

The following presets where defined:"
  TmpMail.UserName:= 'whatever@gmail.com';
  TmpMail.Password:= 'ASecurePassword';
  TmpMail.Stmp:= 'smtp.gmail.com:465';
  TmpMail.Address:= 'ToEmail@email.co.za';
  TMpMail.FromAddress:= 'whatever@gmail.com';
  TMpMail.Subject:= 'Subject testl';
  TmpMail.Attachment:= 'c:\Test\blank.xlsx';


Procedure TForm4.Sendmail(Mail: MyEmailType);
Var
  m:TMimemess;
  l:tstringlist;
  p: TMimepart;
begin
  m:=TMimemess.create;
  l:=tstringlist.create;
  try
    p := m.AddPartMultipart('mixed', nil);
    l.loadfromfile(Mail.Attachment);
    m.AddPartText(l,p);
    m.AddPartBinaryFromFile(Mail.Attachment,p);
    m.header.from:= Mail.FromAddress;
    m.header.tolist.add(Mail.Address);
    m.header.subject:= Mail.Subject;
    m.EncodeMessage;
    memo1.lines.assign(m.lines);
    //if you wish to send it by SMTP too, then:
    If SendToRaw(Mail.FromAddress, mail.Address, Mail.Stmp, M.lines, Mail.UserName, Mail.Password) then
    ShowMessage('Email sent') else
      ShowMessage('Email not sent');
  finally
    m.free;
    l.free;
  end;
end;

Thank you in advance

Sammy

  • Newbie
  • Posts: 2
Re: Sending an email (using synapse)
« Reply #1 on: January 18, 2024, 05:45:07 pm »
I have successfully created a Delphi app that sends and receives GMail using Indy10.
My SMTP component has a property .UseTLS.  The only setting I have found that works is utUseExplicitTLS.
hope this helps.
you can read about mapp at SamsChessBoard.ddns.net

 

TinyPortal © 2005-2018