This is because the razor does not know when to start processing C # code. You must explicitly specify a razor when interpreting C # ...
<a rel="nofollow" href=" @(string.Format("mailto:?subject={0}&body={1}", ViewBag.Title, ViewBag.Description + "%0D%0A" + ViewBag.Url))>Share by Email </a>
Edit
Answer
I got carried away with the sitanks mistakes you had in your razor. However, even after you edited your question, I still see some problems. The first problem is that you open two brackets, but close only one. The second problem is that you specify an empty email address, well, you should at least add a space (not html encoded). And the last question is that you do not actually separate the subject and body because you use ? instead of & . If you fix these problems, you should be good to go. Here is an example based on your question ...
<a rel="nofollow" href="@(String.Format("mailto: ?subject={0}&body={1}" , "The title" , "The description" + "%0D%0A" + "http://theurl.xyz"))"> share by email </a>
This should work as it is. But if you want to do more funky things, please read this RFC
Leo
source share