WindowsMobileMailTransportBindingElement Class
Represents the mail transport binding element for Windows Mobile powered devices.
Assembly: Microsoft.ServiceModel.Channels.Mail.WindowsMobile (in Microsoft.ServiceModel.Channels.Mail.WindowsMobile.dll)
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 Shared ChannelName As String = "Channel1" Private Shared DestinationEmailAddress As String = "someone@example.com" Private Shared serializer As New CFMessagingSerializer(GetType(String)) Shared Sub Main(ByVal args() As String) Dim factory As IChannelFactory(Of IOutputChannel) Dim listener As IChannelListener(Of IInputChannel) Dim output As IOutputChannel Dim input As IInputChannel Dim bpc As BindingParameterCollection Dim mailTransportBindingElement As MailTransportBindingElementBase Dim msgEncodingBindingElement As MessageEncodingBindingElement Dim message As Message Dim str As String Dim binding As System.ServiceModel.Channels.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(Of IOutputChannel)(bpc) listener = binding.BuildChannelListener(Of IInputChannel)(MailUriHelper.CreateUri(ChannelName, "")) factory.Open() output = factory.CreateChannel(New EndpointAddress(MailUriHelper.Create(ChannelName, DestinationEmailAddress))) output.Open() message = System.ServiceModel.Channels.Message.CreateMessage(MessageVersion.Default, "urn:Test", "Hello, World!", serializer) output.Send(message) output.Close() factory.Close() listener.Open() input = listener.AcceptChannel() input.Open() message = input.Receive() str = message.GetBody(Of String)(serializer) MessageBox.Show(str, "Received message") input.Close() listener.Close() mailTransportBindingElement.Close() End Sub End Class
System.ServiceModel.Channels.BindingElement
System.ServiceModel.Channels.TransportBindingElement
Microsoft.ServiceModel.Channels.Mail.MailTransportBindingElementBase
Microsoft.ServiceModel.Channels.Mail.WindowsMobile.WindowsMobileMailTransportBindingElement
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.