Tutorials
Resources
Forum
Reviews
Communities
Interview
Jobs
Projects
Training
Your
Ad
Here
Silverlight Games
|
Mentor
|
Code Converter
|
Articles
|
Code Factory
|
Computer Jokes
|
Members
|
Peer Appraisal
|
IT Companies
|
Bookmarks
|
Polls
|
Revenue Sharing
|
Lobby
|
Gift Shop
|
Prizes & Awards
My Profile
Sign In
Register
AdSense Revenue
Active Members
Today
krishnavenikal...
(12)
Nikhil Gaur
(10)
Randhir Yadav
(1)
Last 7 Days
Anil Kumar ...
(582)
Nikhil Gaur
(561)
Abhisek Panda
(445)
more...
Resources
»
Code Snippets
»
Email
»
Sending Inline Attachments Thru E-Mail
Posted Date: 23 Jul 2008
Resource Type:
Code Snippets
Category:
Email
Author:
Muralidhar
Member Level:
Bronze
Rating:
Points
: 10
The following is the code snippet to send inline attachment thru System.Net.Mail:
Include the namespace System.Net.Mail
1. Create a new MailMessage object:
MailMessage msg = new MailMessage(fromAddress, toAddress);
2. Create the LinkedResource:
LinkedResource logo = LinkedResource("c:\\test.jpeg");
3. Create the ContentId for the LinkedResource:
logo.Contentid = "CompanyLogo";
4. Create the AlternateView object and assign the required view:
AlternateView htmlView = AlternateView.CreateAlternateViewFromString("The embeded image is:
", null, "text/html");
5. Add the LinkedResource created in step2 to the AlternativeView created in step 4:
htmlView.LinkedResources.Add(logo);
6. Add the AlternativeView created in step 4 to the MailMessage object created in step 1:
msg.AlternativeViews.Add(htmlView);
7. Create SmtpClient object to send e-mail:
SmtpClient email = new SmtpClient();
email.UseDefaultCredentials = true;
email.Host = myHost; // Specify the host name
email.Send(msg);
Thanks,
Murali.
Responses
No responses found. Be the first to respond and make money from
revenue sharing program
.
Feedbacks
Popular Tags
What are tags ?
Search Tags
Sign In
to add tags.
Mail Attachment
.
Inline Attachment
.
.NET
.
Post Feedback
This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must
Sign In
to post a response.
Next Resource:
Sending E-Mail through SQL Server stored procedures
Previous Resource:
HTML E-mail with images
Return to Discussion Resource Index
Post New Resource
Category:
Email
Post resources and
earn money
!
Related Resources
Sending E-Mail through SQL Server stored procedures
Send Email using Gmail
How to send E-mail from .NET applications
Reading mails from microsoftOutlook
E-mail validation using regular expression
Mail using ASP.NET , c#
dotNet Slackers
About Us
Contact Us
Privacy Policy
Terms Of Use