开发者

How to send email attachments/small files using WCF?

开发者 https://www.devze.com 2023-03-21 21:21 出处:网络
I want to ask you about sending files using WCF. I want to implement service, to send fax and emails. My case looks like that:

I want to ask you about sending files using WCF. I want to implement service, to send fax and emails. My case looks like that:

  • The service will be hosted in windows service.
  • I would like to make this service visible on the local network only. (So I will probably use netTcpBinding)
  • and It will be great, when a customer who wants to send a fax or send email with attachments, will have to use only the "SendFax" function with specific parameters. I mean.. How to do that, so it would be very simple for client?
  • I think the biggest attachm开发者_StackOverflow中文版ent could be up to 20MB, I don't know how it looks like in case of a fax. But I think it will be MS Word file, so 20MB will upper limit.

I want to ask you how to implement, the server-side part of WCF service? Use buffered upload or streamed upload ? Could you give me a link to good example or article ?

Any help will be great, Thanks


A WCF service endpoint can accept a byte array of variable sizes so it shouldn't be a problem for a client to send a pdf,word, etc document as a byte[] to the service. The default netTcpBinding settings will need to be adjusted to accomodate the large file sizes.


Your windows service will host your WCF endpoint (e.g., SendDocument()).

The service's implementation of this method will use the standard System.Net.Mail.SmtpClient class to send the email. See the MSDN documentation for SmtpClient and especially the MailMessage class, which among other things has an Attachments property you can use.

0

精彩评论

暂无评论...
验证码 换一张
取 消