473,385 Members | 1,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Send email with html body using System.net.mail

Now i am sending email to my friend using session variable...

but my code is as below

private bool SendEmail(string email)
{

try

{

using (MailMessage mail = new MailMessage())
{

string msgBody="";
string message = "";

//Load the template page for the email template.

BlogEngine.Core.Page page2 = BlogEngine.Core.Page.GetPage(new
Guid(Session["Content"].ToString() ));
//Take the link for the main content page and add it to the content.
Use HTML breaks.

msgBody = page2.AbsoluteLink + "<br/>";msgBody += page2.Content + "<br/
>";

//Take the content for the email heading intro message. This is hard
coded guid for the virtual page in the admin we created for sending
the email

BlogEngine.Core.Page page = BlogEngine.Core.Page.GetPage(new
Guid("ff8f0685-9f6a-4758-855d-6018d9542963"));
message = page.Content;

// Add the 911 intro

msgBody = message + "<br/>" + msgBody;
//Email is from 911

mail.From = new MailAddress(BlogSettings.Instance.Email);
//This should add fields from the form for the user's name and thier
email

MailAddress ma = new MailAddress(this.txtTo.Text,
this.txtFriendsName.Text);
mail.To.Add(ma);

mail.Subject = page.Title;

//page content includes html

mail.IsBodyHtml = true;
//mail.BodyFormat = System.Web.Mail.MailFormat.Html;

// AlternateView PlainView =
AlternateView.CreateAlternateViewFromString("This is my Plain text
Content, Viewable by those client that dont support html", null, "text/
Plain");

//AlternateView htmlView =
AlternateView.CreateAlternateViewFromString("<b>th is is bold text, and
Viewable by those client that support html </b>", null, "text/html");

//mail.AlternateViews.Add(PlainView);

//mail.AlternateViews.Add(htmlView);

mail.Body = msgBody;

//mail.BodyEncoding = System.Text.Encoding.UTF8;

//mail.BodyEncoding.IsBrowserSave = true;

//mail.Body = msgBody;



Utils.SendMailMessage(mail);
}

return true;
}

catch (Exception ex)
{

if (User.Identity.IsAuthenticated)
{

if (ex.InnerException != null)
lblStatus.Text = ex.InnerException.Message;

else

lblStatus.Text = ex.Message;

}

return false;
}

}

eventhogh i did mail.Isbodyhtml = true....

my email shows html tags in it i dont need that...how can i get that
do u hav any idea?
Nov 6 '08 #1
0 2126

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
5
by: nate heaton | last post by:
I would like to do the following with C# in my asp.net app: Open the default email client of the user (just like a mailto: link would). Supply the subject line and put some HTML (including an...
3
by: Ed Sutton | last post by:
How can I show the email client UI so the user can send the attachment to the desired recipient. I get an exception if I leave the MailMessage.To property blank. Is there any way to do this? I...
1
by: Miguel Dias Moura | last post by:
Hello, Can you help me out in making this work? What I want is as simple as sending form values to an email. The code I am using is the following:
3
by: Gerard | last post by:
Hello I have created a windows service to monitor a database, it starts some checks when a timer elapses. The checks send emails depending on their findings. My issue is that when I created a...
3
by: Frank | last post by:
I am attempting to develop a solution where I handle bounced e-mails. I wish to field all bounced emails in a custom email account such a bounced@mycompany.com From the aricle at...
4
Frinavale
by: Frinavale | last post by:
Introduction Many .NET applications will require an email be sent out for various reasons. This article will give a quick examples on how to send an email using VB.NET. The examples given can...
2
by: Malli mindwave | last post by:
Hi, We are using the yahoowebHostiing service for my company website, In that one screen of the SendComments/FeedBack section is there, I'm basically dot.net develeoper ,but yahoowebhosting not...
2
by: anu b | last post by:
Now i am sending email to my friend using session variable... but my code is as below private bool SendEmail(string email) { try
3
by: anu b | last post by:
Hii I am using System.net.mail for sending email... i need to send a webpage with its html content as my email body .....for that i used mail.Isbodyhtml as true...but it is not working for me...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.