Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am using WYSIWYG editor control in my application.Created Content Management system to send email notification,but email subscribers are getting email with HTML tags

How to remove the tags from email?

I am storing text present in editor in database also,here it stored including tags,
and same data displaying in email with tags also.

Is the problem with editor or my code?
The code as follows:
  SmtpClient smtpClient = new SmtpClient();
    MailMessage message = new MailMessage();
    try
    {
        StringBuilder sb = new BAL.PageContent().EmailList();
        string s = sb.ToString().Trim().TrimEnd(',');

        MailAddress fromAddress = new MailAddress("info@captorsolutions.com");
        message.From = fromAddress;//here you can set address
        message.To.Add(s);
        message.Subject = "Aghoryan Email Notification";//subject of email
        // message.CC.Add("cc@site.com");//ccing the same email to other email address
        //message.Bcc.Add(new MailAddress("bcc@site.com"));//here you can add bcc address
        message.IsBodyHtml = true;//To determine email body is html or not
        message.Body = string.Format("<html><body>" + ucEditor1.Content + "</body></html>");
        smtpClient.Send(message);
    }
    catch (Exception ex)
    {
        //throw exception here you can write code to handle exception here
    }
}


Thanking you ..
Posted
Comments
CodingLover 5-Oct-11 1:38am    
In which format that editor returns, HTML or plain text?
srinivas vadepally 5-Oct-11 1:41am    
HTML format only
Ed Nutting 5-Oct-11 2:30am    
You want to send non-html emails right? So why have you set message.IsBodyHtml as true? Surely that should be set to false to stop any html tags being added in for you. Furthermore, your code appears to be adding in html and body tags for itself! If you don't want them, delete them! message.Body = string.Format(ucEditor1.Content);Hope this helps, Ed :)
srinivas vadepally 5-Oct-11 3:36am    
Hi edward,
it is working fine for text and when i insert the text and image,it doesn't work
help me out
please...
Ed Nutting 5-Oct-11 15:41pm    
Hi, okay so have you tried just image? I would have thought that the image is adding in img tags to be able to insert it. Try just inserting a url for the image - unless you wish to faff with inserting binary image data into an email this is your easiest option for adding images in an email - unless fo course you attach the images but that doesn't work well as above 2 images and the email will become to big for most servers to handle.

Hope this helps,

Ed :)

1 solution

You have to make sure that the clients that recieve the email has HTML Viewing enabled otherwise they will receive this content in plain text format. Have you tested this by sending it to yourself? Check your Email Application settings.
 
Share this answer
 
Comments
Ed Nutting 5-Oct-11 15:44pm    
Never view emails in HTML - they are prone to viruses/phishing attacks/cloning and can be very dangerous - always with in plain text. Also, if the user is not connected to the internet, sending plain text emails is best for offline viewing as style sheets ect may not have been downloaded before the user went offline - in this situation the user would end up with a partial render rather than a decent plain text one!

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