گروه‌های Google دیگر از اشتراک‌ها یا پست‌های جدید Usenet پشتیبانی نمی‌کند. محتوای قدیمی قابل‌مشاهده باقی می‌ماند.

Send email with html body using System.net.mail

۲ بازدید
رفتن به اولین پیام خوانده‌نشده

anu b

خوانده‌نشده،
۱۶ آبان ۱۳۸۷، ۱۵:۳۹:۲۶۱۳۸۷/۸/۱۶
به
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>this 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?

0 پیام جدید