0

MVC3, VB.NET. I have a function in my app that is supposed to use a html file's contents for the email body. However what I have so far is failing at the mail.body = file.readalltext(_body) line.. Any ideas??

   <Authorize(Roles:="Admin")>
    Function Notification(ByVal _email As String) As ActionResult


        Dim _body = Path.Combine((AppDomain.CurrentDomain.BaseDirectory) + "HtmlEmails\") + "HolidayEmail.htm"

        Dim SmtpServer As New SmtpClient()
        Dim mail As New MailMessage()
        mail.To.Add(_email)
        mail.From = New MailAddress("[email protected]")

        mail.Subject = "Happy Holidays From xxxxx"
        mail.Body = File.ReadAllText(_body)
        mail.IsBodyHtml = True
        Dim smtp As New SmtpClient("mail.xxxxxxxxx.com")
        smtp.Credentials = New System.Net.NetworkCredential("[email protected]", "xxxxxxxxxx")
        smtp.Port = "587"
        smtp.Send(mail)

        Return RedirectToAction("LogOn", "Account")
    End Function
4
  • Have you verified that the _body variable contains the correct path/filename and that your app has the rights to read from that path? Commented Nov 29, 2011 at 16:59
  • Please, bring the exception details. Commented Nov 29, 2011 at 17:01
  • It doesn't compile.. It says that Overload resolution failed because no accessible 'File' accepts this number of arguments. Commented Nov 29, 2011 at 17:05
  • _body does contain the correct path and proper permissions as well.. Commented Nov 29, 2011 at 17:06

1 Answer 1

2

Change mail.Body = File.ReadAllText(_body) to mail.Body = System.IO.File.ReadAllText(_body).

File is also a member of Controller.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.