Use indy SMTP to send Gmail messages in Delphi [Go]

Source: Internet
Author: User
Tags mailmessage

use indy SMTP to send Gmail messages in Delphi [Go]

2012-01-01 22:44:30|  Category: Delphi | Tags: | Report | Font size Big medium small subscription

   e-mail in Delphi is very simple, the way to send SSL Gmail email is also very simple, as long as the use of idsmtp attached to a tidssliohandlersocket on it. Using Controls  procedure SendMail (Stomail, Ssubject, scontent:string);var    smtp:tidsmtp;    mailmessage:tidmessage;    sslsocket:tidssliohandlersocket;begin  SMTP        := Tidsmtp.create (Nil);  sslsocket: = Tidssliohandlersocket.create (nil);  mailmessage:= TIdMessage.Create ( Nil);   SMTP. Iohandler: = sslsocket;  SMTP. Port  : = 465;  SMTP. Host: = ' smtp.gmail.com ';  smtp. AuthenticationType  := atlogin;   SMTP. UserName    : = ' SunnyYu2000 ';  smtp. Password      := ' xxxxxx ';  //Set message   MailMessage.From.Address: = ' [email  Protected] ';  MailMessage.Recipients.EMailAddresses: = stomail;  Mailmessage.subject: = Ssubject;    MailMessage.Body.Text: = scontent;  //Send mail   try    try    &NBSP Smtp. Connect (+);      SMTP. Send (MailMessage);      ShowMessage (' send Success ');    except on e:exception do      Sho Wmessage (' Send failed: ' + e.message ');    end;  finally    if SMTP. connectedthen      SMTP. disconnect;  end;   mailmessage.free;  sslsocket.free;  SMTP. Free;end, after compiling, requires the support of SSL dynamic library, which can be downloaded to the Indy website. If you need to send an attachment, you can send it again before you add the following similar code     //add attachments to the message    tidattachment.create (Mailmessage.messageparts, Sattachmentfilename); ———— –indy required SSL Support DLL http://www.indyproject.org/Sockets/SSL.EN.aspx

Use indy SMTP to send Gmail messages in Delphi [go]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.