简体   繁体   中英

How to send email attachments/small files using WCF?

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 attachment 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 (eg, 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM