.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh

Home >> Code Snippets >> Email >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Html Email with Image embedded

Posted By:Jean Paul       Posted Date: October 18, 2011    Points: 40    Category: Email    URL: http://www.dotnetspark.com  

Html Email with Image embedded

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.Net;
using System.Net.Mime;

namespace HtmlEmailWithImage
    class Program
        // Gmail Constants
        public const string SMTPServer = "smtp.gmail.com";

        // Set your user name and password here
        public const string AdminEmail = "from@gmail.com";
        public const string AdminPassword = "pwd";

        public const string RecipientEmail = "to@gmail.com";

        // Message Constants
        public const string Message = "

Html Email with Image

        public const string ImagePath = "Baloons.png";

        static void Main(string[] args)
            MailMessage message = new MailMessage(AdminEmail, RecipientEmail);
            message.IsBodyHtml = true;
            message.Subject = "Html Email with Image";

            AlternateView view = AlternateView.CreateAlternateViewFromString(Message, null, MediaTypeNames.Text.Html);
            LinkedResource resource = new LinkedResource(ImagePath);
            resource.ContentId = "id1";


            SmtpClient client = new SmtpClient(SMTPServer);
            client.Credentials = new NetworkCredential(AdminEmail, AdminPassword);
            client.EnableSsl = true;


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend