SMTPSecureSocket addhandler error

  1. ‹ Older
  2. 3 years ago

    Richard A

    21 Oct 2015 Pre-Release Testers, Xojo Pro

    Thanks Wayne, that was it!

  3. Norman P

    21 Oct 2015 Xojo Inc North of 50

    YOU never pass anything
    It needs to be declared with an instance as the first parameter as that's how the RUNTIME calls whatever event you're defining
    You never call this event directly so YOU never pass anything
    The runtime calls the event this way

    Thats why I asked what MailSent looked like

  4. Richard A

    21 Oct 2015 Pre-Release Testers, Xojo Pro

    @Norman P

    It looks like:

    	Sub MailSentEvent(Sender As SMTPSecureSocket)
    		  Call UpdateTransaction("", "", "App Sent")
    		  MsgBox("In Sent")
    	End Sub

    It compiles but it doesn't fire.

  5. Norman P

    21 Oct 2015 Xojo Inc North of 50

    whats the code to start sending ?
    and you dont make the thing go out of scope before all are sent ?
    you do poll the socket ?

    as you can see there are a few reasons it might not get called - primarily the send queue never empties for some reason

  6. Richard A

    21 Oct 2015 Pre-Release Testers, Xojo Pro

    Here's the code where the email gets sent.

    SMTPServerMail is a Property, Type SMTPSecureSocket
    In the window open event:

      SMTPServerMail = New SMTPSecureSocket
      AddHandler SMTPServerMail.MailSent, AddressOf MailSentEvent

    In a method the Mail is sent:

      SMTPServerMail.Address = "localhost" 'csBulkMailSMTPServerMail
      SMTPServerMail.Port = 25 'cnBulkEmailPort
      SMTPServerMail.Username = ""   'csBulkMailSMTPUserID
      SMTPServerMail.Password = ""   'csBulkEmailSMTPPassword
      
      
      System.DebugLog("Last Error: " + Str(SMTPServerMail.LastErrorCode) )
      
      Msg.AddRecipient csEmailAddress
      System.DebugLog("Sending email to: " + csEmailAddress)
      Msg.subject = "Application Form - " + rs.Field("lastName").StringValue + ", " + rs.Field("firstName").StringValue + " " + rs.Field("middleName").StringValue
      Msg.BodyHTML = CreateMsg()
      SMTPServerMail.Messages.Append( Msg)
      
      Call UpdateTransaction("", "", "Sending App")
      SMTPServerMail.SendMail
      

    Have I missed something?

  7. Norman P

    21 Oct 2015 Xojo Inc North of 50

    What happens AFTER SMTPServerMail.SendMail is called ?
    Does the window close ?

  8. Richard A

    21 Oct 2015 Pre-Release Testers, Xojo Pro

    No The WebPage does not close, unless the user closes it, but I don't.

  9. Norman P

    21 Oct 2015 Xojo Inc North of 50

    one way to test why they dont get sent is to put a loop right after sendmail that just polls it periodically until bytes left to send = 0

  10. Richard A

    21 Oct 2015 Pre-Release Testers, Xojo Pro

    I'll try it tomorrow and report.

    Thanks for the help Norman!

  11. Richard A

    22 Oct 2015 Pre-Release Testers, Xojo Pro

    I put the loop in and the event still didn't fire.

    While SMTPServerMail.BytesLeftToSend > 0 SMTPServerMail.Poll WEnd MsgBox("Out of Polling")

  12. Norman P

    22 Oct 2015 Xojo Inc North of 50

    Have you added handlers for the other events as well ?
    I'm wondering if there's errors etc that are occurring but since there's no handler you don't know it

  13. Richard A

    22 Oct 2015 Pre-Release Testers, Xojo Pro

    No but the email is going through.

    I will try adding the other events and let you know.

  14. Norman P

    22 Oct 2015 Xojo Inc North of 50
    Edited 3 years ago

    ah so only the event that is when all mails have been sent isnt firing

    hmmm .....

    there's only one email though ?

    bytes left to send is for one message so maybe poll like

     While SMTPServerMail.Messages > 0
        SMTPServerMail.Poll
      Wend
    
      MsgBox("Out of Polling")
  15. Richard A

    23 Oct 2015 Pre-Release Testers, Xojo Pro

    Tried that and got Type Missmatch Expected class EmailMessage, but got int32 so went back to BytesLeftToSend.

    I've implemented more events, will let you know.

  16. Richard A

    23 Oct 2015 Pre-Release Testers, Xojo Pro

    I added ConnectionEstablished and Servererror, Neither of them fired.

  17. Norman P

    23 Oct 2015 Xojo Inc North of 50

    well connection established not firing would be an issue
    no emails will be sent without connection

  18. Richard A

    23 Oct 2015 Pre-Release Testers, Xojo Pro

    Except I can confirm that an email was sent.

  19. Richard A

    23 Oct 2015 Pre-Release Testers, Xojo Pro

    What I'm trying to do is after the email is sent, write a confirmation to the database that an email has been sent. There have been a few instances where the email did not get sent. I believe it has to do with some server issues.

    Can you think of way to get this fixed?

  20. Norman P

    23 Oct 2015 Xojo Inc North of 50

    a small sample of this code with a bug report would be a start

  21. 5 weeks ago

    James M

    Nov 9 South Devon England

    I have exactly the same problem, but looks like this conversation died before a conclusive answer was given. :-(

or Sign Up to reply!