473,569 Members | 3,063 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(strin g 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(n ew
Guid(Session["Content"].ToString() ));
//Take the link for the main content page and add it to the content.
Use HTML breaks.

msgBody = page2.AbsoluteL ink + "<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(n ew
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(Blo gSettings.Insta nce.Email);
//This should add fields from the form for the user's name and thier
email

MailAddress ma = new MailAddress(thi s.txtTo.Text,
this.txtFriends Name.Text);
mail.To.Add(ma) ;

mail.Subject = page.Title;

//page content includes html

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

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

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

//mail.AlternateV iews.Add(PlainV iew);

//mail.AlternateV iews.Add(htmlVi ew);

mail.Body = msgBody;

//mail.BodyEncodi ng = System.Text.Enc oding.UTF8;

//mail.BodyEncodi ng.IsBrowserSav e = true;

//mail.Body = msgBody;



Utils.SendMailM essage(mail);
}

return true;
}

catch (Exception ex)
{

if (User.Identity. IsAuthenticated )
{

if (ex.InnerExcept ion != null)
lblStatus.Text = ex.InnerExcepti on.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 2147

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

Similar topics

0
9859
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 ********************************** package Celcom.Client;
5
4400
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 image) into the body of the email. Any help would be greatly appreciated. -- Nate Heaton
3
5045
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 found a Microsoft example that uses mapi32.dll that can do this. But I can nopt make the SmtpMail work like I want. Thanks in advance, -Ed
1
2146
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
4544
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 windows application it worked fine, however I need to use a service as I don't want to rely on a user being logged in. The errors I get are: Index...
3
5401
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 http://www.systemwebmail.com/faq/2.7.aspx, I gather I could use: mail.Headers.Add( "Reply-To", "alternate_email@mycompany.com" ); When I test this from a test...
4
17445
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 easily be translated into C#.NET. Storing Email Credentials If you are developing a web application the best place to store your email credentials is...
2
5624
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 support .asp,.aspx files, it supports PHP files, I'm searching in JavaScript ,but not found any matter, I'don't Know PHP.I'm having lot of...
2
18162
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
7234
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 so pls help me....
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7619
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7681
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5228
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3662
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.