473,382 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Passing a MailMessage object to a web service

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.

Any assistance gratefully received.

Best regards,

Mark Rae
Nov 15 '05 #1
4 7750
"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
Nov 15 '05 #2
"Joe Mayo [C# MVP]" <jm***@nospamAtCSharpDashStation.com> wrote in message
news:OZ**************@TK2MSFTNGP11.phx.gbl...

Joe,

Thanks very much for your reply.
2. You can use WSE and add the object to a DIME packet. This would be the most efficient way to do this.
OK - I've done a Google search and haven't come up with much. Can you point
me at a resource somewhere which will get me started?
3. There are probably a few other ways to accomplish this in a creative
manner.


I'm sure! I also fully agree with you that this isn't a particularly
sensible thing to do, but my client is my client and has asked me to
investigate if it can be done and, as I enjoy having my invoices paid, I'm
going to try do it for them... :-)

Mark
Nov 15 '05 #3


"Mark Rae" <ma**@markrae.co.uk> wrote in message
news:O4**************@TK2MSFTNGP11.phx.gbl...
"Joe Mayo [C# MVP]" <jm***@nospamAtCSharpDashStation.com> wrote in message
news:OZ**************@TK2MSFTNGP11.phx.gbl...
2. You can use WSE and add the object to a DIME packet. This would be the
most efficient way to do this.


OK - I've done a Google search and haven't come up with much. Can you

point me at a resource somewhere which will get me started?


I recommend WSE 1.0 w/SP1 because it is a fully supported release:

http://www.microsoft.com/downloads/d...displaylang=en

There are samples in the docs on how to use DIME. Also, check out the
tracing facilities - they're lifesavers sometimes.

There is a WSE 2.0, but it is an unsupported technology preview and I
wouldn't do much but experiment with it at this time. Also, here is the URL
to the Web Services Center on MSDN. They have a lot of good content:

http://msdn.microsoft.com/webservices/
3. There are probably a few other ways to accomplish this in a creative
manner.


I'm sure! I also fully agree with you that this isn't a particularly
sensible thing to do, but my client is my client and has asked me to
investigate if it can be done and, as I enjoy having my invoices paid, I'm
going to try do it for them... :-)


Yep, I know all too well. ;)

Joe
--
http://www.csharp-station.com
Nov 15 '05 #4
"Joe Mayo [C# MVP]" <jm***@nospamAtCSharpDashStation.com> wrote in message
news:OZ**************@TK2MSFTNGP11.phx.gbl...
1. You can use the System.Encoding types to convert the object to a byte
array and pass it across.


Help! I thought this would be a trivial task, but I'm having real difficulty
with it! If I have the following code:

using System.Web.Mail;

MailMessage objMailMessage = new MailMessage();
/*
code here to assign the message properties
*/

how do I then convert the object into a byte array, and then (optionally)
turn it into a Base64 string? Presumably, stitching it back into a
MailMessage object once it's been passed to the web service is simply a
matter of reversing the process...?

Mark
Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ryan Malone | last post by:
Passing Dictionary object byref Ive created an ASP class that uses a dictionary object which is filled from a recordset. It passes the object to the propterty of another ASP class byref: ...
1
by: Michael J. Ryan | last post by:
can anyone point out some examples of this? essentially, I want to have a service application that controls inbound connections, and a console/control application that communicates with it to...
8
by: Dennis Myrén | last post by:
I have these tiny classes, implementing an interface through which their method Render ( CosWriter writer ) ; is called. Given a specific context, there are potentially a lot of such objects,...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
1
by: Wade Wegner | last post by:
Hello, Using the MailMessage class (or any other ASP.NET SMTP classes), I would like to programmatically request a read receipt. Is this possible? I have found an article that talked about a...
1
by: vbvjain | last post by:
Hi Thanks for your suggestion, i even tried that but now the error that is generated is "There was an error generating XML". If i declare the input parameter of my web service method as object and...
0
by: Carlos | last post by:
Hmm it should be fairly simple i guess, but im stuck big time. Cant seem to find iDataSource anywhere. What im trying to do is to read a textfile (mail.mai) into an CDO Mailmessage object. So...
4
by: Ant | last post by:
Hi, I'm using the MailMessage object to send an email programmatically via a console application. It needs to have lines breaks. For example: string s = "This is the first line + "\n\r" + "and...
9
by: Greger | last post by:
Hi, I am building an architecture that passes my custom objects to and from webservices. (Our internal architecture requires me to use webservices to any suggestion to use other remoting...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.