Oruns Dru Oruns Dru - 3 years ago 165
C# Question

How to paste formatted text in textbox

I have this app that sends bulk emails. I want the user to press a button that will paste the emails into a textbox which is quite easy.

Now, I want each email to have a semi-colon at the end and a space between it and another email. Anyone have an idea on how I can go about that.

Answer Source

Use the clipboard class to retrieve information from the clipboard.

public String RetrieveClipboardHtmlText(String replacementHtmlText)
    String returnHtmlText = null;
    if (Clipboard.ContainsText(TextDataFormat.Html))
        returnHtmlText = Clipboard.GetText(TextDataFormat.Html);
    return returnHtmlText;

As for the other issue, your emails are going to need some sort of delimiter. Otherwise it'd be impossible to tell where the top level domain ends for one email ( IE .com, .org, .biz) and the next email begins, so its just going to be pretty simple string manipulation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download