C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to add photos in mail...


Posted Date: 05 Jul 2008      Total Responses: 1

Posted By: nilesh bahirshet       Member Level: Gold     Points: 1



(I "dont" want to "attach" the photos....)
I want to send mail with photos,,,
How to show the text with images in Mail ?





Responses

Author: VijayKumar Reddy M    25 Jul 2008Member Level: GoldRating:     Points: 6

Namespaces Used

using System.Net.Mail;
using System.Net.Mime;



CODE

// send mail to the new user who has registered.
protected void yourButton_Click(object sender, EventArgs e)
{

string strMailContent = "Welcome new user";
string fromAddress = "yourname@yoursite.com";
string toAddress = "newuser@hisdomain.com";
string contentId = "image1";
string path = Server.MapPath(@"images/Logo.jpg"); // my logo is placed in images folder
MailMessage mailMessage = new MailMessage( fromAddress, toAddress );
mailMessage.Bcc.Add("inkrajesh@hotmail.com"); // put your id here
mailMessage.Subject = "Welcome new User";


LinkedResource logo = new LinkedResource(path);
logo.ContentId = "companylogo";
// done HTML formatting in the next line to display my logo
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("localhost"); //use this if you are in the development server
mailSender.Send(mailMessage);

}

Note:SmtpClient mailSender = new SmtpClient(ConfigurationManager.AppSettings["MyCustomId"]); // use this in the Production Server. I have specified my email server in the web.config file





Post Reply
You must Sign In to post a response.
Next : Syntax to create object for the proxy class(.vb file) in jscript
Previous : Web Service Problem "302 Found"
Return to Discussion Forum
Post New Message
Category: Webservices

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use