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

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

Telling when an iframe is done loading

100% positive, 1 comment - last added on Sep 07, 2008 at 10:57 pm
– Tip added by an anonymous user on Apr 18, 2008 at 8:05 am

Something to consider before switching platforms

100% positive, 0 comments
– Tip added by an anonymous user on Sep 25, 2007 at 7:31 pm

Length of associative arrays in Javascript

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

Random number generation

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

Optional parameters in javascript functions

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

Detecting if a variable exists in Javascript

100% positive, 1 comment - last added on Sep 03, 2008 at 6:12 am
– Tip added by an anonymous user on Jul 22, 2008 at 8:31 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

Copyright date on sites

Categories: web programming php Smarty
100% positive, 0 comments
– Tip added by an anonymous user on Mar 11, 2008 at 8:14 am

Javascript variable naming

100% positive, 1 comment - last added on Jul 22, 2008 at 8:33 am
– Tip added by an anonymous user on Sep 30, 2007 at 7:28 am

Avoiding facebook timeout errors

Categories: Facebook programming web
100% positive, 0 comments
– Tip added by an anonymous user on Aug 21, 2007 at 5:21 pm

Creating charts in PHP

no ratings, 0 comments
– Tip added by an anonymous user 4 days, 8 hours ago

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

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