Android Question NET Library, SMTP and the Sender Object

Discussion in 'Android Questions' started by SeaCay, Jun 15, 2015.

  1. SeaCay

    SeaCay Member Licensed User

    Hello All,

    My question revolves around the Sender object which I believe should be trappable in the "MessageSent" event. To be quite clear on this I am not talking about the sender (email address) of the message, but I am referring to the sender object representing the object that sent the message.

    The Wiki says...
    My testing shows that the sender (as SMTP) object is always null. This arises even when my originating SMTP object is still in global scope (please don't suggest using the global object). I am hoping that the quoted Wiki entry is true for all objects but I seem unable to trap the SMTP object.

    Is this correct that Sender is not available in the MessageSent event?

    As always, I thank you for your help and support.

    regards

    SeaCay
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You are correct. It will be fixed.
     
  3. SeaCay

    SeaCay Member Licensed User

    Thanks Erel

    regards

    SeaCay
     
  4. SeaCay

    SeaCay Member Licensed User

    Hello Erel,

    Please can you advise if this issue has been corrected? Or. if not, a potential fix date?

    regards and thanks

    SeaCay
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    It was fixed but not released. Send me an email to erel@basic4ppc.com and I will send you the updated library.
     
  6. SeaCay

    SeaCay Member Licensed User

    Hello Erel,

    I have implemented the Net library you sent yesterday.
    Although the Sender object is no longer Nil, the Sender attributes don't seem to have any values.
    For example, from the MessageSent event:

    Code:
    Dim aMsg As SMTP
    Dim aSbj As String
       
            aMsg = 
    Sender
            aSbj = aMsg.Subject
    When examining the aSbj variable, it is an empty string.

    Do you know why this would be so?

    regards

    SeaCay
     
    Last edited: Sep 2, 2015
  7. Erel

    Erel Administrator Staff Member Licensed User

    The SMTP object values are cleared when you call Send to allow developers to reuse it to send more messages.

    I guess that you are using multiple SMTP object, right?
    In that case you can use a Map to map between the objects (keys) and any other values.
     
  8. SeaCay

    SeaCay Member Licensed User

    Hello Erel,

    Again my thanks for getting back to me so quickly.

    I understand what you have said but I wonder if clearing the SMTP object values is something the application developer should do? Of course having made that point I do not know how the SMTP object has been written so it could be difficult/impossible for the application developer to clear.

    So here's my thinking,
    I create, configure and dispatch a SMTP message.
    I have a message event (MessageSent) triggered that accesses a SMTP Sender object.
    But the Sender object has been cleared along the way, so it is of no use to me for post dispatch evaluation.
    Surely if the sender has been cleared, the SMTP(sender) object copied to the MessageSent Event it is meaningless?
    And this probably explains why it was nil at the outset of this discussion thread.

    What I am trying to do

    One of my apps sends many emails to various government departments. One of the email messages has a keyword in the subject that I use as a trigger to prevent further processing. I need to know that the message has been sent successfully and therefore need the MessageSent event for both the success status variable and to know to which message the success relates from the presence of a keyword in the subject. If the Sender.subject could be evaluated, I could trigger the code to prevent further activity from within the MessageSent event. In short I need the Sender.Subject and the success status flag to complete this task.

    I value your thoughts.

    regards and thanks

    Colin
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    Are you using multiple SMTP objects?
     
  10. SeaCay

    SeaCay Member Licensed User

    Hello Erel,

    I am using one only SMTP object.

    I have decided to change my approach and redirect the "MessageSent" event for the termination message to a different, compliant event handler.
    This way I can get most of the info I need and determine send success/failure. Early testing indicates that this is sufficient.

    If you should update/re-write the SMTP object so that it is not cleared between sending and notification, please let me know.

    Many thanks for your help.

    regards

    SeaCay
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    You should send the messages one by one. Send the next message from MessageSent event. This way you will always know which message was sent.

    The performance will be the same as SMTP sends a single message each time.
     
Loading...