Email from HTML file with WCF Service

105 Views Asked by At

Please help me. I can't transform the HTML file to a string variable. I tried this but in WCF doesn't work. Thanks so much.

/// another service
SWCorreoServicioClient cMail = new SWCorreoServicioClient();

string subject = "test";
string body = string.Empty;

// This line doesn't work
body = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Doc/index.html"));

cMail.sendMail=("mailto@example", subject, body);

1

There are 1 best solutions below

1
Ernesto Gutiérrez Márquez On

I found a solution... Instead

body = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Doc/index.html"));

I made this:

string path = HostingEnvironment.MapPath("~/Doc/index.html");
body = File.ReadAllText(path);

And that was all. :)