Software Components Home

How to Load an Email Body from a Text File

Back

Question:

I just purchased your .NET components.. and they work great.. I have a question concerning sending a text message in the body of the EMail.. do you have a way to use a text file as input to a body or do I have to use a string with line formatting etc..

What I want to do is send a rather long text message to a cell phone.. the report is already generated to fit the screen (I think)..

Any help or words of wisdom would be greatly appreciated.

Answer:
Yes, the Chilkat.Charset2 class contains this method:

public string ReadFileToString(string filename, string srcCharset); 

Reads a text file and returns the text converted to a Unicode string. 
The filename is specified by the first method argument, and the charset 
of the text data is specified by the 2nd method argument. 
You could use it to read any text file (in any character encoding) and then assign the email.Body property to the string. If your text is English, use "windows-1252" for the charset.
There is no source code associated with this article.