简体   繁体   中英

Copy paste from clipboard in c# windows text box in the same format

I want to copy from word or excel or any other external application into my applications textbox or richtextbox and save and retrieve the data in the same format, this would be used as a message body for sending emails.

Can anybody guide me through this?

You could get content from Word or Excel (or any other app) in html format end this would be ideal for email :

string data = Clipboard.GetText(TextDataFormat.Html);

You will get html string but with some header in front, look at the links below for examples how to handle it :

http://blogs.msdn.com/b/jmstall/archive/2007/01/21/html-clipboard.aspx

http://theartofdev.wordpress.com/2012/11/11/setting-html-and-plain-text-formatting-to-clipboard/

warning html produced by word is simply horrible so probably there will be problems for some people when viewing such mails with messy html.

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