Today I found these useful links that helps us to embed the images in the HTML emails we are sending using ASP.NET & C#. You can download the example code of sending HTML emails using ASP.NET here... http://www.asp101.com/Samples/email_html_aspx.asp http://download.microsoft.com/download/d/f/c/dfc7a022-3426-4868-b23c-3818a6e54305/HtmlEmail.zip
Simple HTML Format emails::
private void SendClick() {
MailMessage mailMsg = new MailMessage();
try {
mailMsg.To = "
mailMsg.From = "
mailMsg.BodyFormat = MailFormat.Html;
mailMsg.Subject = "Statistics Report";
mailMsg.Body ="content";
SmtpMail.SmtpServer ="serverHost";
SmtpMail.Send(mailMsg);
}
catch (Exception ex) {
Response.Write(ex.Message);
}
}
To have a basic idea of mailing with an embedded image or object from ASP.NET 2.0 using SMTP Client. You can visit the following links...
http://aspalliance.com/1354_Sending_HTML_Mail_with_Embedded_Image_in_NET.8
http://www.codeproject.com/kb/IP/EmailByjebarson.aspx
http://www.codeproject.com/KB/aspnet/inkrajesh.aspx
Friday, June 06, 2008
Sending HTML Emails using ASP.NET, C# with embedded images
Sending emails using ASP.NET, C# or VB.NET
For sending mails from asp.net, C# Using System.Web.Mail name space.
using System.Web.Mail;
public static string SendMail(int pintUserID, string pstrMailTo, string pstrMailBcc,string pstrMailCc,string pstrMailSubject,string pstrMailBody,string pstrAttachFilePath){
try
{
MailMessage objMail = new MailMessage();objMail.From = System.Configuration.ConfigurationSettings.AppSettings["FromEmailID"];
//objMail.From =System.Web.HttpContext.Current.Session["OfficeEmailID"].ToString() ;
objMail.To = pstrMailTo;
objMail.Bcc = pstrMailBcc;
objMail.Cc = pstrMailCc;
objMail.Subject = pstrMailSubject;
MailAttachment Attachment = null;if (File.Exists(pstrAttachFilePath)){
Attachment = new MailAttachment(pstrAttachFilePath);}
objMail.Attachments.Add(Attachment);
SmtpMail.SmtpServer = "localhost";//System.Configuration.ConfigurationSettings.AppSettings["SMTPServerIP"];
SmtpMail.Send(objMail);return "TRUE";}
catch(Exception Ex){
return Ex.Message;}
}
In Config file
<add key="SMTPServerIP" value="192.168.1.11"> </add>
Call this function SendMail & enable your system SMTP server.
Useful links for sending email
http://www.asp101.com/Samples/email_html_aspx.asp
http://download.microsoft.com/download/d/f/c/dfc7a022-3426-4868-b23c-3818a6e54305/HtmlEmail.ziphttp://www.codeproject.com/KB/aspnet/Email_Sending_Programme.aspx