"Mark Rae" <ma**@markrae.co.uk> wrote in message
news:OR******************@TK2MSFTNGP11.phx.gbl...
Hi,
Can anyone please tell me if it's possible to pass a
System.Web.Mail.MailMessage object to a ASP.NET Web Service? Maybe using
XML Serialization / Deserialization? I've been asked to investigate the
possibility of building a front-end web page which captures MailMessage
properties such To, From Subject, Attachments etc, builds a MailMessage
object, passes the MailMessage object to a web service, the web service
then sends the message via the Smtp.Send method.
Hi Mark,
Because the MailMessage type is not Serializable, passing it directly to the
Web Service is difficult. Additionally, once you pass a .NET type to a Web
Service, it is no longer accessible via systems other than .NET, i.e. those
built with Java, Perl, or any other language/platform. If you must pass the
MailMessage, here are a couple ideas:
1. You can use the System.Encoding types to convert the object to a byte
array and pass it across. I believe this would bloat the message being sent
to the Web Service and hurt performance pretty badly. You could turn the
byte array into a Base64 string and pass it as a string parameter, which
would be better because it would eliminate tags around every byte.
2. You can use WSE and add the object to a DIME packet. This would be the
most efficient way to do this.
3. There are probably a few other ways to accomplish this in a creative
manner.
If the ultimate goal is to get the Web Service to send an email, I would
just collect the information that is going to go into the message and send
each piece of information as a parameter to the Web Service. Then I would
have the Web Service instantiate the MailMessage object and then send the
email. This also makes the Web Service interoperate with other platforms,
which is one of the big benefits of Web Services.
Joe
--
http://www.csharp-station.com