Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
hi,

I am sending html email it's working but only download options is display how to view my email template in asp.net:
C#
string strMailContent = "Welcome new user";
       
        string cid = "banner.jpg";
        string path = Server.MapPath(@"images/banner.jpg"); // my logo is placed in images folder
        MailMessage mailMessage = new MailMessage();
        MailAddressCollection addcoll = new MailAddressCollection();
        addcoll.Add("kollihari1209@gmail.com");
        addcoll.Add("kollihari1209@gmail.com");
        mailMessage.From = addcoll[0];
        mailMessage.To.Add(addcoll[1]);
        mailMessage.Subject = "Welcome new User";
        LinkedResource logo = new LinkedResource(path);
        logo.ContentId = "banner";
       
        AlternateView av1 = AlternateView.CreateAlternateViewFromString("<html><body><img src=cid:companylogo/>     <br></body></html>" + strMailContent, null, MediaTypeNames.Text.Html);
        av1.LinkedResources.Add(logo);
        mailMessage.AlternateViews.Add(av1);
        mailMessage.IsBodyHtml = true;
        SmtpClient mailSender = new SmtpClient(); 
        mailSender.Host = "smtp.gmail.com";
        mailSender.Port = 587;
Posted
Updated 7-May-12 10:15am
v2
Comments
Sergey Alexandrovich Kryukov 7-May-12 14:41pm    
Reason for my vote of 1:

Not clear at all. And not a question.

If you don't care about comprehensive issue report and explanation of your goal and failures, who would care to answer?

--SA
Kolli Hari Chowdary 7-May-12 14:45pm    
Hai........Actually the mail(html template) is sending from asp.net with out any errors...but the html template is not viewing in mail..it showing download option only..

1 solution

MailMessage Class is now obsolete. Microsoft's recommended alternative: System.Net.Mail[^].

Moving ahead, see this thread discussion: Can I set up HTML/Email Templates with ASP.NET?[^] - it has various good ways discussed on how to make a template and use it. Check out, if they help.

Few others based on MailMessage class to go through if they help:
Email Templates[^]
Sending Email using Templates Asp.net [^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 7-May-12 16:32pm    
Should help, my 5.
--SA
Sandeep Mewara 8-May-12 8:26am    
Thanks SA.

Finally, it looks like Chris resolved the issue and now we can post comments. :)
Sergey Alexandrovich Kryukov 8-May-12 12:40pm    
Let me try... works! :-)
--SA
Monjurul Habib 8-May-12 16:40pm    
5!
Sandeep Mewara 9-May-12 0:53am    
Thanks.

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