I have an SMTPsecureSocket, subclassed as emailSocketClass, and provided as a property (myMailSocket) as part of the app object.
If an error occurs during an email send, I would like the error event of the socket to advise the user.
I therefore do this in the app.init method, called at app.open.
myMailSocket = new emailSocketClass
AddHandler myMailSocket.Error addressOf mailError
where mailError is a method in app
The line addHandler myMailSocket.Error fails with a “EmailSocketClass has no member named .Error” - which is not what the docs say about SMTPsecureSocket.
If I change this to
AddHandler myMailSocket.writeError addressOf mailError
it fails with a syntax error.
More info.
If I add an emailSocketClass instance to a window, by drag and dropping the class on the window, the new socket thus created does have the event “.Error” available to it.
So the class is OK. But it’s not allowed in the App object it would seem.
Any thoughts here ? I have a ridiculously simple project which shows this behaviour …
Good catch. Otherwise, it looks like you’re referring to a method, Error, that takes an argument, AddressOf mailError, and returns an value to AddHandler. There is no Error method or event so defined.
Yes I was missing a comma, which cured the syntax error.
Autocomplete does not offer the expected Error event:-
AddHandler myMailSocket.Error <- this does not autocomplete
biut it does compile when I write
AddHandler myMailSocket.writeError, addressOf mailError
I am setting up the mailSocket to intentionally fail (by putting in a wrong address for the mail server) and no emails are sent when I do this. If I enter the correct address it does send (and I receive the email sent at the other end).
I am confident the email link can work, but I cannot get any indication of error from the event.
Try ServerError instead of Error. Error is for non-specific errors. A bad address should be caught in ServerError. (Note: I didn’t test this before replying.)
Unfortunately, ServerError does not autocomplete; and the addHandler line fails with a typeMismatch error.
Hi Michel,
WriteError may not be in the docs but it is the only thing close to Error which does autocomplete.
Error is in the docs but the event does not fire under any circumstances I can generate.
Despite this may I say thank you to all those who have replied. I am able to place a SMPTsecureSocket on a window and use that (and it does have a usable Error event, which does fire). While I would like to use events in code, they don’t seem to work here.
If there are any hardy souls who wish to see a very simple demo project of the issue, I would be pleased to post it to a web page for your viewing pleasure.
Hi Tim,
I am sure that it works. I very much doubt that Xojo Inc would send it out with such a basic part being Dead.
My issue is that after having done what the instructions say, I have non-functionality.
In your case, did you subclass the SMPTsecureSocket before instantiating it in code ? And did you explicitly call the super’s constructor ? I have tried both and neither seem to vary my results.
Ah well. I am sure that the answer is out there. Many thanks for your thoughts, Tim. I will persevere.
[quote=235828:@Tony Barry]WriteError may not be in the docs but it is the only thing close to Error which does autocomplete.
Error is in the docs but the event does not fire under any circumstances I can generate.[/quote]
Autocomplete is a function of the IDE which while convenient, is not the ultimate reference. And there are several places where it does not autocomplete (for instance System). You should always refer to the doc, and enter manually if it does not autocomplete.
I hate to break it to you, but when you type SMTPSecureSocket in Developer.Xojo.Com, the page that displays is in fact from the old LR in an iframe :
Thank you for your reply. Yes, I would gather that Autocomplete is less perfect that the docs … but it is more perfect than I am.
Hence my reliance on a fallible tool.
Regarding the old versus the new developer docs; well, I am just glad for any insight. No need to be reluctant to tell me the truth - I would rather know the truth and be found ignorant, than be ignorant squared.