Solved

Email send as HTML Format but received as text.

Posted on 2010-11-24
13
634 Views
Last Modified: 2012-05-10
Dear Friends,

I am working on a Group discussion forum. The members are all registered members. On registration I send an email thanking for registration and a link to click and confirm their email id. This mail is send in html format but on testing with my gmail, hotmail, yahoo and rediffmail ids I found that the link is plain text and is not clickable.

using System.Web.Mail and not the lates System.Net.Mail.

Please advise.
0
Comment
Question by:MadhuMenong
  • 3
  • 3
  • 2
  • +4
13 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34203826
Can you post the code you are using to send the message? Have you set the BodyFormat property of the MailMessage to MailFormat.Html?
0
 
LVL 29

Expert Comment

by:Kumaraswamy R
ID: 34203855
hi


example  :

using System;
using System.Web.Mail;

namespace WebMail
{
    class Class1
    {
        static void Main(string[] args)
        {
            try
            {
                MailMessage oMsg = new MailMessage();
                // TODO: Replace with sender e-mail address.
                oMsg.From = "sender@somewhere.com";
                // TODO: Replace with recipient e-mail address.
                oMsg.To = "recipient@somewhere.com";
                oMsg.Subject = "Send Using Web Mail";
               
                // SEND IN HTML FORMAT (comment this line to send plain text).
               
oMsg.BodyFormat = MailFormat.Html;
               
                // HTML Body (remove HTML tags for plain text).
                oMsg.Body = "<HTML><BODY><B>Hello World!</B></BODY></HTML>";
               
                // ADD AN ATTACHMENT.
                // TODO: Replace with path to attachment.
                String sFile = @"C:\temp\Hello.txt";  
                MailAttachment oAttch = new MailAttachment(sFile, MailEncoding.Base64);
 
                oMsg.Attachments.Add(oAttch);

                // TODO: Replace with the name of your remote SMTP server.
                SmtpMail.SmtpServer = "MySMTPServer";
                SmtpMail.Send(oMsg);

                oMsg = null;
                oAttch = null;
            }
            catch (Exception e)
            {
                Console.WriteLine("{0} Exception caught.", e);
            }
        }
    }
}
0
 
LVL 14

Expert Comment

by:Dhanasekaran Sengodan
ID: 34203859
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 7

Accepted Solution

by:
mr_nadger earned 333 total points
ID: 34204850
try oMsg.IsBodyHtml = True;
(that's from a VB app I've written, C# may be a little different, but there is a property for forcing it to use HTML format)
0
 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 34205054
Before send the mail using code just create Email body and copy it to file and view it in browser. By way you can find what problem you are facing.
0
 

Author Comment

by:MadhuMenong
ID: 34210739
Sorry friends for not responding. Currently I am working on an other issue and will come back to this by evening.
Please bear with me.
Thank you.
0
 
LVL 3

Expert Comment

by:DaveKeyes
ID: 34211902
The solution from mr Nadger is correct, this is how I do it in a common method I wrote.  It comes across as a HTML formatted email.
0
 
LVL 3

Expert Comment

by:DaveKeyes
ID: 34211905
Also, mine is written in c#.
0
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 167 total points
ID: 34211922
@DaveKeyes

The solution by Mr Nadger is NOT correct since he is using the MailMessage out of the System.Net.Mail namespace, whereas the question clearly states that the asker is using the older System.Web.Mail namespace.
0
 
LVL 3

Expert Comment

by:DaveKeyes
ID: 34211974
I apologize, you are correct, I over looked that.
0
 
LVL 7

Assisted Solution

by:mr_nadger
mr_nadger earned 333 total points
ID: 34211976
oops missed that, should it be newmail.BodyFormat = MailFormat.Html?
0
 
LVL 7

Expert Comment

by:mr_nadger
ID: 34212002
0
 

Author Closing Comment

by:MadhuMenong
ID: 34215375
Thanks a lot.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question