Forum > Beginners

Project fails on run but works with run to cursor and step through.

(1/2) > >>

gjunk:
Win 10, Laz 3.2
I have a project that creates a pdf from a form and sends that form as an attachment to an email.
It compiles and runs but fails to send the email.
If I set the cursor on the call to create the email and use run to cursor, it creates the email and sends it successfully when I use f7 or f8 to continue from that point.
I have installed the latest Lazarus.
I compiled the ide with the needed packages. Synapse4.
It uses x-mailer, smtpsend and openssl-09.8d
It is odd that it works when I step through it and fails when I executes from the run command.
On failure it gives me the E:Exception message.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TestXM(Subject,fname:String;Var Result:Boolean); var  Form5: TForm5; implementation {$R *.lfm}procedure TestXM(Subject,fname:String;Var Result:Boolean);var  Mail: TSendMail;begin  Mail := TSendMail.Create;  form5:=Tform5.Create(Nil);  Form5.Show;  Form5.Memo1.Clear;  Form5.Memo1.Append('Building Email ....');try    Mail.Sender := dfr.SmtpMailfrom;//dfr.Store+'Shiftinfo@no.net';   // Show up as sender    Mail.Receivers.Add(dfr.SmtpMailto); //('################');    If dfr.cc1 >'' then      Mail.Receivers.Add(dfr.cc1);    If dfr.cc2 >'' then      Mail.Receivers.Add(dfr.cc2);    Mail.Subject := Subject; //'Test pdf file attached';    Mail.Message.Add('Shiftwork');    // SMTP    Mail.Smtp.UserName :=dfr.smtpU;  //'1test@######.com';    Mail.Smtp.Password := dfr.SmtpPass; //##########;    Mail.Smtp.Host := dfr.SmtpS; //'mail.######.com';    Mail.Smtp.Port := Trim(dfr.SmtpP);    If Mail.Smtp.Port ='465' then    begin      Mail.Smtp.SSL := True;      Mail.Smtp.FullSSL:=true;      Mail.Smtp.TLS:=False;    end    else     begin       Mail.Smtp.SSL := True;       Mail.Smtp.FullSSL:=False;       Mail.Smtp.TLS:=True;     end;     Form5.Memo1.Append('Adding Attachment ....');     Mail.Attachments.Add(fname);      // add attachment     Mail.Send;    Result:=True;    Windows.beep(1000,300);   Form5.Memo1.Append('Email send is successful!');    Windows.beep(1000,300);  except    on E:Exception do    begin      Windows.beep(100,300);      Form5.Memo1.Append('Email send FAILURE!');      Showmessage('Email failed');      Windows.beep(100,300);    end;  end;  Mail.free;  Form5.free; end;      

dseligo:
Try to see what error you get with this:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---ShowMessage(E.Message);

Thaddy:
Possibly the openssl version is way to old. In that case the server will refuse the protocol used and you will get no or an erronious error. you must use openssl1.1.1 or better openssl3. this error can be seen weekly on this forum.
I can already see that with your wrog code here;
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---      Mail.Smtp.SSL := True;//wrong!      Mail.Smtp.FullSSL:=true;//-----wrong!      Mail.Smtp.TLS:=False;----wrong!
that can be replaced by just;
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---      Mail.Smtp.TLS:=true; //tls superceded ssl a long time agossL as such is not supported, TLs1.0, 1.1 may be supported. the default is usually tls 1.2 or tls 1.3.

You must update both openssl and synapse to a more recent version.

gjunk:
Showmessage(E.Message) displays

Unable to open file "710032824SHL.pdf": The system cannot find the file specified.

The pdf was created in the correct directory with the proper filename.

I will look into the newer ssl/tls stuff when i fix this.

Zvoni:

--- Quote from: gjunk on March 28, 2024, 02:24:54 pm ---Showmessage(E.Message) displays

Unable to open file "710032824SHL.pdf": The system cannot find the file specified.

The pdf was created in the correct directory with the proper filename.

I will look into the newer ssl/tls stuff when i fix this.

--- End quote ---
Did you pass the path to the File, too?
A Path to a file is part of the Filename itself

Navigation

[0] Message Index

[#] Next page

Go to full version