简体   繁体   中英

Delphi with indy

I just started using indy10 (today) in Delphi 2010, after reading everywere i managed to make it work, i can send emails using gmail, it works fine on my computer, but when i install the application on my laptop (for tests), it doesnt send the email and my app stops working, do i have to install something else on my laptop or how can i make it to work on every computer i install my program, so far i have to install it on 6 different computers, some use windows XP and some Windows 7, i hope there is a way to make it multiplatform or something.

This is my code:

procedure SendIndyMail;
begin

    Form_final.IdSMTP1 .IOHandler := Form_final.IdSSLIOHandlerSocketOpenSSL1;
    Form_final.IdSMTP1.Host:= 'smtp.gmail.com';
    Form_final.IdSMTP1.Password:= 'xxxxxx';
    Form_final.IdSMTP1.Port := 587;
    Form_final.IdSMTP1.UseTLS := utUseExplicitTLS;
    Form_final.IdSMTP1.Username := 'xxxxxx';

    Form_final.IdSSLIOHandlerSocketOpenSSL1.Destination := 'smtp.gmail.com:587';
    Form_final.IdSSLIOHandlerSocketOpenSSL1.Host := 'smtp.gmail.com';
    Form_final.IdSSLIOHandlerSocketOpenSSL1.Port := 587;
    Form_final.IdSSLIOHandlerSocketOpenSSL1.SSLOptions.Method := sslvTLSv1;
    Form_final.IdSSLIOHandlerSocketOpenSSL1.SSLOptions.Mode := sslmUnassigned;
    Form_final.IdSSLIOHandlerSocketOpenSSL1.SSLOptions.VerifyMode := [];
    Form_final.IdSSLIOHandlerSocketOpenSSL1.SSLOptions.VerifyDepth := 0;

    Form_final.IdMessage1.Subject:=conect.Q_selec_info_generalDescripcion.Text+' '+DateToStr(Date);
    Form_final.IdMessage1.Recipients.EMailAddresses:=conect.Q_config_seleccorreo.Text;
    TIdAttachmentFile.Create(Form_final.IdMessage1.MessageParts, conect.Q_config_selecfolder.Text+'\reporte_'+FormatDateTime('dddd d of mmmm yyyy', Date)+' Inventario '+Form_inventario.Edit_id_inventario.Text+'.pdf');

    Form_final.IdSMTP1.Connect;
    Form_final.IdSMTP1.Send(Form_final.IdMessage1);
    Form_final.IdSMTP1.Disconnect;
end;

I ran the proyect on my laptop and it says:

Could not load SSL Library, now, i did many things to make it work, downloaded many things and tried many other, now i dont know where those libraries are and how to retrieve them, and i would like to know of a way to load them with the installation so my installer goes with everything needed.

Thanks in advance.

Make sure you have the OpenSSL DLLs on your target machines, preferrably in your app's installation folder. If you still get the error, Indy's WhichFailedToLoad() function in the IdSSLOpenSSLHeaders unit can tell you why it could not load the OpenSSL DLLs. As for the DLLs themselves, you can download Indy-compatible copies from Indy's Fulgan mirror .

On a side note, you do not need to set the IOHandler's Destination , Host , or Port properties. The Connect() method will handle that internally for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM