0

Here is the C# part

for (int i = 0; i <= mailergrd.Rows.Count - 1; i++)
{
    SBEmailBody.Append("<'html><'body><table><tr><td>  Dear  <b> <name>,    </td></tr></table></b>  <br/><br/>  Welcome  <br/>" + "hiii.<br/>"+</body></html>");

    SBEmailBody.Replace("<name>", mailergrd.Rows[i]["Name"].ToString());

    System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(),     "SendMail"+i, "SendMail('[email protected]','" + SBEmailBody.ToString() + "','Greetings     from PDAC','[email protected]');", true);
}

Here is the JavaScript part

function SendMail(to,body,sub,cc)
{
    var theApp;  
    var theMailItem;  
    var subject = sub;
    var msg = body;
    var carbon = cc;

try
{
    var theApp = new ActiveXObject("Outlook.Application");        
    var theMailItem = theApp.CreateItem(0);
    theMailItem.To = to;
    theMailItem.Subject = (subject);
    theMailItem.CC = carbon;
    theMailItem.Body = (msg); 
    theMailItem.Display();
 } 

OUTPUT

<html><body><table><tr><td>  JOHN <b> ,</td></tr></table></b> <br/><br/> Welcome <br/>" + "hiii.<br/>" +</body></html>

I'm trying to send E-Mails from client-side which is working fine except for the body of the mail: its not html formatted while passing from code behind.

2 Answers 2

0

You need to pass the HTML formatted string to theMailItem.HTMLBody property, not .Body.

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

Comments

0

I Think Many Questions Like these have Been Answered Before.

Return HTML from ASP.NET Web API Have a look at that and See if its a possible Solution.

1 Comment

Thank you Retic for your response but HttpResponseMessage property is asking for a class to create and more over im not using MVC, could you please help me more on this..!

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.