//Called by SoapSmtpOutputChannel.Send(). Implementing
        //this on the transport instead of the channel keeps all references to
        //transport-specific network resources inside of the transport class, and keeps
        //the channels clean.
        internal void Send( SoapEnvelope e, EndpointReference destination )
        {
            //Create a new mailbox based on the TransportAddress of the endpoint. Again,
            //we use TransportAddress instead of Address to allow soap.smtp:// endpoints to
            //act as intermediaries.
            Mailbox box = new Mailbox( destination.TransportAddress, _options );

            //Send the message via SMTP.
            box.Send( e, destination.TransportAddress );
        }
Example #2
0
 //Creates a new MailClientAsyncResult and begins an asynchronous receive operation.
 //When this operation completes, it will call the specified AsyncCallback, carrying the specified
 //Mailbox instance as its AsyncState.
 //Note that this class derives from Microsoft.Web.Services3.AsyncResult, which gives us
 //a lot of useful features.
 public MailClientAsyncResult( Mailbox box, AsyncCallback callback )
     : base(callback, box)
 {
     //Initiate the asynchronous operation using the ThreadPool. Sooner or later,
     //this will result in the Receive() method being called.
     ThreadPool.QueueUserWorkItem( new WaitCallback( this.Receive ) );
 }
        //Creates a new mailbox and stores it in the mailboxes collection if one
        //does not already exist for the specified URI.
        internal Mailbox FindOrCreateMailbox( Uri uri )
        {
            lock ( _mailboxes )
            {
                if ( !_mailboxes.Contains( uri ) )
                {
                    Mailbox box = new Mailbox( uri, _options );
                    _mailboxes.Add( uri, box );
                }

                return ( Mailbox )_mailboxes[ uri ];
            }
        }