Export (0) Print
Expand All

WindowsMobileMailBinding Class

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Represents the mail binding for Windows Mobile devices.

Namespace:  Microsoft.ServiceModel.Channels.Mail.WindowsMobile
Assembly:  Microsoft.ServiceModel.Channels.Mail.WindowsMobile (in Microsoft.ServiceModel.Channels.Mail.WindowsMobile.dll)

public sealed class WindowsMobileMailBinding : MailBindingBase

WindowsMobileMailBinding is a sealed class that represents the mail binding for Windows Mobile devices. The mail binding enables you to synchronize messages with a Microsoft Exchange server.

The base class, MailBindingBase, contains most of the functionality used by this class.

The WindowsMobileMailBinding class includes a collection of binding elements such as an encoding element and a transport binding element. The predefined encoding element for this class is TextMessageEncodingBindingElement, and the predefined transport binding element is WindowsMobileMailTransportBindingElement.

The following example shows how to use the WindowsMobileMailBinding class in the context of sending and receiving messages.

The custom serializer is not specific to the Exchange Server mail transport and is not included in this example.


class Program
{
    private static string ChannelName = "Channel1";
    private static string DestinationEmailAddress = "someone@fabrikam.com";

    private static CFMessagingSerializer serializer = new CFMessagingSerializer(typeof(string));

    static void Main(string[] args)
    {
        // For desktop applications, use ExchangeWebServiceMailBinding 
        // instead of WindowsMobileMailBinding.
        WindowsMobileMailBinding binding;
        IChannelFactory<IOutputChannel> factory;
        IChannelListener<IInputChannel> listener;
        IOutputChannel output;
        IInputChannel input;
        BindingParameterCollection bpc;
        Message message;
        string str;

        // For desktop applications, use ExchangeWebServiceMailBinding.
        binding = new WindowsMobileMailBinding();
        bpc = new BindingParameterCollection();

        factory = binding.BuildChannelFactory<IOutputChannel>(bpc);
        factory.Open();
        output = factory.CreateChannel(new EndpointAddress(MailUriHelper.Create(ChannelName, DestinationEmailAddress)));
        output.Open();

        message = Message.CreateMessage(MessageVersion.Default, "urn:Test", "Hello, World!", serializer);
        output.Send(message);

        output.Close();
        factory.Close();

        listener = binding.BuildChannelListener<IInputChannel>(MailUriHelper.CreateUri(ChannelName, ""), bpc);
        listener.Open();
        input = listener.AcceptChannel();
        input.Open();

        message = input.Receive();
        str = message.GetBody<string>(serializer);

        MessageBox.Show(str, "Received message");

        input.Close();
        listener.Close();

        binding.Close();
    }
}


System.Object
  System.ServiceModel.Channels.Binding
    Microsoft.ServiceModel.Channels.Mail.MailBindingBase
      Microsoft.ServiceModel.Channels.Mail.WindowsMobile.WindowsMobileMailBinding

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Compact Framework

Supported in: 3.5
Show:
© 2014 Microsoft