Click here to Skip to main content
15,910,411 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
StreamReader reader = new StreamReader(Microsoft.SqlServer.Server.MapPath("~/invitemail.htm"));

i have working on asp.net mail concept.. now i am struggle in that coding.. please help..
i am design a invite mail in my html file and attach to mail body....
i have a error in that above line:
my error is:


CS0234: The type or namespace name 'MapPath' does not exist in the namespace 'Microsoft.SqlServer.Server' (are you missing an assembly reference?)

Posted

Only
C#
Server.MapPath("~/invitemail.htm")
is sufficient. Microsoft.SqlServer does not have a namespace 'Server' (AFAIK).
 
Share this answer
 
Comments
srigates 6-Aug-13 5:31am    
StreamReader reader = new StreamReader(Server.MapPath("~/invitemail.htm"));
if i do like this above code....it have red line under a "Server"..
but i also try in this way also...
//StreamReader reader = new StreamReader(File.OpenText("~/invitemail.htm"));
//StreamReader reader = new StreamReader(File.ReadAllText("~/invitemail.htm"));
Hi,
You can access html and attach in body as below:
C#
string Body = System.IO.File.ReadAllText(Server.MapPath("~/invitemail.htm"));

Hope it helps.
 
Share this answer
 
v2
hi finally i got a solution for this one...
below code is correct one.. i got a solution:
StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/htmldesign.htm"));

thanks to all..
 
Share this answer
 
Comments
Sudarshan M S 7-Jan-16 3:27am    
For the above solution I'm getting the below error. please help me.
"The name "HTTPContext" does not exist in the current context"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900