user897052
user897052

Reputation: 85

What is an efficient way to send email with possibly multiple large attachments via a WCF web service?

I am looking for the best (or at least a very good) way of doing the following:
The client passes the necessary data (i.e. from, to, cc...subject, body etc) as well as attachment files to the service which composes the email using the SmtpClient class and sends it to the recipient(s).

I know how to send an email with the aforementioned fields passed by the client, however I am having difficulty with the attachments, as they could potentially be more than 1 large files of any type. Is it better for the client to pass a Stream object, a byte[] (or possibly a 2D array for >1 attachments) etc. to the service?
Are there are conventions or protocols for this topic? (I'm writing a WCF web service in C#)

Any advice, code, links, etc would be appreciated...

Upvotes: 0

Views: 559

Answers (2)

James Johnson
James Johnson

Reputation: 46067

I would send the outgoing emails to a pickup directory, which will queue them instead of sending them immediately.

Upvotes: 0

rtalbot
rtalbot

Reputation: 1645

You could use MTOM (Message Transmission Optimization Mechanism) to pass the attachment as binary content. Here is a good writeup: http://weblogs.asp.net/ricardoperes/archive/2009/05/14/using-mtom-with-wcf.aspx

Upvotes: 1

Related Questions