Tip Details Add a Related Tip

Rate as: Positive Negative

Adding an email attachment in .Net

I wanted to add an email attachment to a mail message that I was sending (when coding in ASP.Net). This tripped my up for a bit, but it turns out to be really easy. Turns out there is a method to do this on the MailMessage object. Here's how it's done:

-- Start by setting up your mail object. Yours may be different, but here's an example:

Dim objEmail as New MailMessage
objEmail.To = "someone@somecompany.com"
objEmail.FROM = "me@someothercompany.com"
objEmail.BODY = "some message"
etc, etc, etc

-- All that's needed to include the attachment is a call like this:

objEmail.Attachments.Add(new MailAttachment(server.MapPath("/path/to/myfile.txt")))
Rating: 0% positive, 1 Vote
Categories: programming ASP .Net web
Added: on Apr 26, 2007 at 3:49 pm
Added By: an anonymous user
Searches: .net web asp attachment programming

Comments on this Tip

Add a Comment
There are no comments for this tip
Your Comment:
(how to format)
Rate This Tip:

Verify Humanity:
Sorry, we know it's annoying, but please enter the characters shown in the image to the left so that we know you're an actual person and not an evil spammer. Thanks.
       

Related Tips

Setting the button triggered by the enter key

Categories: programming ASP .Net web
100% positive, 0 comments
– Tip added by an anonymous user on Jun 05, 2007 at 6:09 pm

Electronic payment processing in ASP.Net web applications

Categories: programming ASP .Net web
100% positive, 1 comment - last added on Apr 30, 2007 at 1:32 pm
– Tip added by an anonymous user on Apr 25, 2007 at 12:01 pm

Using ASP.Net variables in your Javascript code

100% positive, 2 comments - last added on Sep 04, 2007 at 7:12 am
– Tip added by an anonymous user on May 05, 2007 at 7:00 am

Hex colors in System.Drawing

Categories: ASP .Net web
100% positive, 1 comment - last added on May 27, 2007 at 8:18 pm
– Tip added by an anonymous user on May 25, 2007 at 8:44 am

Master pages in ASP.Net 2.0

Categories: programming ASP .Net
100% positive, 0 comments
– Tip added by an anonymous user on Apr 24, 2007 at 3:05 pm

Maintaining page scroll position with ASP.Net 2.0

Categories: ASP .Net programming
no ratings, 0 comments
– Tip added by an anonymous user on Jun 08, 2007 at 12:31 pm

Detecting if a variable exists in Javascript

100% positive, 2 comments - last added on Oct 21, 2009 at 2:29 pm
– Tip added by an anonymous user on Jul 22, 2008 at 8:31 am

Telling when an iframe is done loading

85% positive, 3 comments - last added on May 16, 2009 at 7:48 am
– Tip added by an anonymous user on Apr 18, 2008 at 8:05 am

Length of associative arrays in Javascript

100% positive, 0 comments
– Tip added by an anonymous user on Nov 04, 2008 at 10:13 am

reading select element values in javascript in IE7

100% positive, 0 comments
– Tip added by an anonymous user on Jul 17, 2009 at 1:28 pm

Optional parameters in javascript functions

100% positive, 0 comments
– Tip added by an anonymous user on Jul 30, 2008 at 10:44 am

Getting answers from Experts Exchange

Categories: programming web
100% positive, 0 comments
– Tip added by an anonymous user on Apr 14, 2009 at 10:57 am

Checking for undefined variables in Javascript

100% positive, 1 comment - last added on Jul 14, 2009 at 5:13 pm
– Tip added by an anonymous user on Jan 14, 2009 at 9:47 am

Random number generation

100% positive, 0 comments
– Tip added by an anonymous user on Aug 05, 2008 at 6:49 am

Redirecting in PHP

100% positive, 0 comments
– Tip added by an anonymous user on Jul 17, 2008 at 7:27 am

compressing javascript

100% positive, 0 comments
– Tip added by an anonymous user on Jun 12, 2008 at 3:02 pm

How to develop extensions for Chrome

no ratings, 0 comments
– Tip added by an anonymous user on Mar 20, 2009 at 6:58 am

Creating charts in PHP

no ratings, 0 comments
– Tip added by an anonymous user on Nov 28, 2008 at 10:37 am

attaching events to nodes in Javascript

no ratings, 0 comments
– Tip added by an anonymous user on Aug 18, 2008 at 11:23 am

animating elements with jQuery

0% positive, 0 comments
– Tip added by an anonymous user on Aug 04, 2008 at 1:46 pm