Source Code for Custom Formatting of E-Mail Messages
The following code is provided to work with Sending a Text E-Mail Message from an Orchestration:
<snippet id="7e635492-9adb-4569-8a27-093d23b3b51c" name="" devlang="CSharp" type="start"/>
using System;
using System.IO;
using System.Text;
using System.Xml.Serialization;
using System.Runtime.Serialization;
using Microsoft.XLANGs.BaseTypes;
namespace Microsoft.Samples.BizTalk.XlangCustomFormatters
{
public abstract class BaseFormatter : IFormatter
{
public virtual SerializationBinder Binder
{
get { throw new NotSupportedException(); }
set { throw new NotSupportedException(); }
}
public virtual StreamingContext Context
{
get { throw new NotSupportedException(); }
set { throw new NotSupportedException(); }
}
public virtual ISurrogateSelector SurrogateSelector
{
get { throw new NotSupportedException(); }
set { throw new NotSupportedException(); }
}
public abstract void Serialize( Stream stm, object obj );
public abstract object Deserialize( Stream stm );
}
public class RawStringFormatter : BaseFormatter
{
public override void Serialize(Stream s, object o)
{
RawString rs = (RawString)o;
byte[] ba = rs.ToByteArray();
s.Write( ba, 0, ba.Length );
}
public override object Deserialize(Stream stm)
{
StreamReader sr = new StreamReader( stm, true );
string s = sr.ReadToEnd();
return new RawString( s );
}
}
[CustomFormatter(typeof(RawStringFormatter))]
[Serializable]
public class RawString
{
[XmlIgnore]
string _val;
public RawString(string s )
{
if (null==s)
throw new ArgumentNullException();
_val = s;
}
public RawString()
{
}
public byte[] ToByteArray()
{
return Encoding.UTF8.GetBytes( _val );
}
public override string ToString()
{
return _val;
}
}
}
<snippet id="7e635492-9adb-4569-8a27-093d23b3b51c" type="end"/>
See Also
Sending E-Mail Using BizTalk Server
To download updated BizTalk Server 2004 Help from www.microsoft.com, go to http://go.microsoft.com/fwlink/?linkid=20616.Copyright © 2004 Microsoft Corporation.All rights reserved.