Bnob said:
I am tring to send email using mail message class in asp.net using
VB.net language.
Can i use a *.txt file as the body arg in mail message class.
Any idea??
bye
You could read the txt file and insert it in a StreamReader. Than read the
stream and create your body string.
e.g.
try
{
using (StreamReader sr = new StreamReader(@"MyFile.txt"))
{
String line;
StringBuilder sb = new StringBuilder();
while ((line = sr.ReadLine()) != null)
{
sb.Append(line);
}
string from = "(e-mail address removed)";
string to = "(e-mail address removed)";
string subject = "MySubject";
string body = sb.ToString();
SmtpMail.SmtpServer = "MyMailServer";
SmtpMail.Send(from, to, subject, body);
}
}
catch (Exception e)
{
//code to manage the exception
}
I write it without test the code, so I hope it's right !
HTH