Recent

Author Topic: sending an email  (Read 16344 times)

cazzajay

  • Jr. Member
  • **
  • Posts: 94
sending an email
« on: November 15, 2009, 05:12:42 pm »
I want to make a program that automatically sends an email to a pre-determined address, for the purposes of "reminding" the user to do something (the program will be a background process type program). Is there a straightforward way of doing this, without invoking the default email client on the machine (strictly speaking, it will be running on a central server in an enterprise network Win32)
Windows XP 32 bit / Lazarus 1.0.6 / FPC 2.6.0

clauslack

  • Sr. Member
  • ****
  • Posts: 275
Re: sending an email
« Reply #1 on: November 15, 2009, 06:45:08 pm »
An example for sending email with Indy.
http://www.lazarus.freepascal.org/index.php/topic,7727.msg36648.html#msg36648

Search in this forum and Wikis for more info about Indy, and other componets for send emails(Inet - http://wiki.lazarus.freepascal.org/lNet)

Regards

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
Re: sending an email
« Reply #2 on: November 15, 2009, 10:13:37 pm »

Hi,
I hope this code helps you. I use Indy 10 and Delphi but also should work with the FPC.
(Components are: IdSMTPServer, IdMessage)
If your SMTP server use authentication then you have to use IdSSLOpenSSL component too.
Thanks.

    Form1.SMTP.Host:='SMTP address of your mail server';
    Form1.SMTP.Port:=25;
    Form1.SMTP.AuthType:=satDefault;
//    Form1.SMTP.AuthType:=satSASL; // if authentication is used.
    Form1.MailMessage.From.Address := 'From Email Address';
    Form1.MailMessage.Recipients.EMailAddresses := 'Recipient Mail Address';
    Form1.MailMessage.Subject:='Subject';
    Form1.MailMessage.Body.Text:='Body';
  try
    try
    Form1.SMTP.Connect;
    Application.processmessages;
      Form1.SMTP.Send(Form1.MailMessage) ;
    except on E:Exception do
      ShowMessage('Sending Error');
    end;
  finally
    if Form1.SMTP.Connected then Form1.SMTP.Disconnect;
  end;


cazzajay

  • Jr. Member
  • **
  • Posts: 94
Re: sending an email
« Reply #3 on: November 18, 2009, 12:42:07 am »
I'm still an idiot - is there an idiot's guide to getting Indy to work on my Lazarus (win32) application?

Thanks for everyone's help thus far!
Windows XP 32 bit / Lazarus 1.0.6 / FPC 2.6.0

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1946
Re: sending an email
« Reply #4 on: November 18, 2009, 10:46:38 am »
Synapse has simple functions for this:

SendTo and SendToEx

http://synapse.ararat.cz/doc/help/smtpsend.html
http://synapse.ararat.cz/

 

TinyPortal © 2005-2018