This documentation is archived and is not being maintained.

WindowsMobileMailTransportBindingElement Class

Visual Studio 2008

Represents the mail transport binding element for Windows Mobile powered devices.

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

public sealed class WindowsMobileMailTransportBindingElement : MailTransportBindingElementBase

WindowsMobileMailTransportBindingElement is a sealed class that represents the mail transport binding element, which is used to construct a mail transport for Windows Mobile powered devices. The mail transport enables you to synchronize messages with an Exchange server (that is, a server that is running Microsoft Exchange Server).

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

After you initialize a new instance of this class, pass the object as an argument in the constructor of a new CustomBinding object.

The following example shows how to use the WindowsMobileMailTransportBindingElement class. It uses a custom encoding element to create the CustomBinding object.

class Program
    private static string ChannelName = "Channel1";
    private static string DestinationEmailAddress = "";

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

    static void Main(string[] args)
        IChannelFactory<IOutputChannel> factory;
        IChannelListener<IInputChannel> listener;
        IOutputChannel output;
        IInputChannel input;
        BindingParameterCollection bpc;
        MailTransportBindingElementBase mailTransportBindingElement;
        MessageEncodingBindingElement msgEncodingBindingElement;
        Message message;
        string str;
        System.ServiceModel.Channels.Binding binding;

        // Instantiate a TextMessageEncodingBindingElement or 
        // a custom encoding binding element. If you use a custom encoding 
        // binding element, messages must be sent as attachments.
        msgEncodingBindingElement = new CustomMessageEncodingBindingElement();
        mailTransportBindingElement = new WindowsMobileMailTransportBindingElement();

        mailTransportBindingElement.MessageContainerType = MessageContainerType.Attachment;
        // In this example, set lifetime to 1 day, 10 hours, 
        // 20 minutes, and 30 seconds.
        mailTransportBindingElement.TimeToLive = new TimeSpan(1, 10, 20, 30);
        mailTransportBindingElement.Transport.MaxTotalMessageCacheSize = 1000;

        binding = new CustomBinding(msgEncodingBindingElement, mailTransportBindingElement);
        bpc = new BindingParameterCollection();

        factory = binding.BuildChannelFactory<IOutputChannel>(bpc);
        listener = binding.BuildChannelListener<IInputChannel>(MailUriHelper.CreateUri(ChannelName, ""), bpc);

        output = factory.CreateChannel(new EndpointAddress(MailUriHelper.Create(ChannelName, DestinationEmailAddress)));


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


        input = listener.AcceptChannel();

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

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



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