Failed to send email with the following error. Error with connecting server; socket error:0x00002746
oSMTP.ServerAddr := 'smtp.gmail.com';
oSMTP.ServerPort := 465;
oSMTP.FromAddr:=email;
oSMTP.Subject :='Payslip for the period:';
osmtp.Username:=email;
oSMTP.Password := smtppassword;
oSMTP.ConnectType:=4;
oSMTP.BodyText:='Please see attached file for payslip details..';
fname :='.\Payslips\payslip.pdf';
if FileExists(fname) then
oSMTP.AddAttachment(fname);
//send mail
if oSMTP.SendMail()= 0 then begin
result := True;
end else begin
ShowMessage('failed to send email with the following error: '
+ oSmtp.GetLastErrDescription());
result := False;
end;