473,378 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Sending an html email with images using C#

Hi i am using this code to send email messages in C#...
Expand|Select|Wrap|Line Numbers
  1.  private void button1_Click(object sender, EventArgs e)
  2.         {
  3.             try
  4.             {
  5.                 MailMessage mail = new MailMessage();
  6.                 SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
  7.  
  8.                 mail.From = new MailAddress("");
  9.                 mail.To.Add("abc@abc.com");
  10.                 mail.Subject = "Test Mail";
  11.  
  12.                 mail.IsBodyHtml = true;
  13.                 string htmlBody;
  14.  
  15.                 htmlBody = "Write <b>some</b> HTML code here";
  16.  
  17.                 mail.Body = htmlBody;
  18.  
  19.                 SmtpServer.Port = 587;
  20.                 SmtpServer.Credentials = new System.Net.NetworkCredential("myusername", "mypassword");
  21.                 SmtpServer.EnableSsl = true;
  22.  
  23.                 SmtpServer.Send(mail);
  24.                 MessageBox.Show("mail Send");
  25.             }
  26.             catch (Exception ex)
  27.             {
  28.                 MessageBox.Show(ex.ToString());
  29.             }
  30.         }
  31.  
The above code works well what i need is the integration of images in an email messages. Can somebody help me to add some lines to it so that it can send html messages with embedded images...Thanks
May 24 '11 #1
1 2578
GaryTexmo
1,501 Expert 1GB
I've never done this myself, but a lot of results turn up with a google search. This one looks like it might be promising...

http://blog.devexperience.net/en/12/...tachments.aspx

In a lot of cases, it helps to try google with something along the lines of "C# <what you want to do>" and it usually pans out.

Good luck!
May 24 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Ann | last post by:
Hi, I am trying to send a html email from a php script. This script emails a common information to all the members in the database. The only problem is I cannot specify colors, hyperlinks...
2
by: Brett | last post by:
I have a client that wants to send HTML based email. Building and sending isn't a problem, but he wants to include a plain text link at the top of the email that will display if the user doesn't...
4
by: Francois Keyeux | last post by:
hello everyone: i have a web site built using vbasic active server scripting running on iis (it works on either iis 50 and 60, but is designed for iis 50) i know how to create a plain text...
0
by: Dan Morrissey | last post by:
I'm trying to initiate an email with predetermined Subject and HTML formatted body that will allow the user to select the recipients from their own address book. The problem is that I can't seem...
2
by: Paul Turley | last post by:
Does anyone have some sample code for sending an HTML formatted message using CDONTS? Thanks RE: Sending HTML formatted mail using CDONTS -- Paul Turley, MCSD, MCAD, MCT, MSF...
4
by: Justin | last post by:
I have a fairly large piece of html, about 50 lines that I would like to send via an ASP.NET page I was wondering what would be the best and cleanest way to do this? Is there a way I can put the...
0
by: MRW | last post by:
I've been looking all over for a solution, and I've found similar problems, but nobody with an answer. Any help would be appreciated. I have a template for an HTML email which is an aspx file...
0
by: shaolinman829 | last post by:
My collegue and I are at the point of pulling our hair out. I'm currently writting a little piece of Java code to send an email confirmation page that sends both html and text. Not a problem. In my...
2
by: Aneesh Pulukkul[MCSD.Net] | last post by:
Hi, I have a HTML page and associated images. I need to send the HTML as email -the email should also display the images at respective places. So am sending the content of HTML file as...
1
by: praveenkrg | last post by:
Hi, Can any one tell me about how to send the HTML mail. I have able to send mail in text format but i want it attractive. Plz help me.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.