Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 18th, 2006, 07:47 AM
Authorized User
 
Join Date: Dec 2005
Location: Bangalore, , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to kapi.goel
Default System.Web.HttpException: Invalid mail attachment

I am facing


System.Web.HttpException: Invalid mail attachment
'C:/Documents and Settings/kapil/Desktop/LoadToBooking.xls'

The code is as follows:-

MailMessage eMail = new MailMessage();

eMail.From = this.txtSEmail.Text;
eMail.To = this.txtREmail.Text;
eMail.Cc = this.txtCC.Text;
eMail.Bcc = this.txtBCC.Text;
eMail.Subject = this.txtSubject.Text;
eMail.Body = this.txtBody.Text;

filePath = this.txtAttachFilePath.Value;

if (filePath.Length > 0)
eMail.Attachments.Add(new MailAttachment(filePath, MailEncoding.Base64));

SmtpMail.SmtpServer = "aaa.xxx.yyy.yyy";
SmtpMail.Send(eMail);





KG
__________________
KG
Reply With Quote
  #2 (permalink)  
Old April 18th, 2006, 12:05 PM
Authorized User
 
Join Date: Apr 2006
Location: , , .
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

your file path is not correct? 'C:/Documents and Settings/kapil/Desktop/LoadToBooking.xls'

Reply With Quote
  #3 (permalink)  
Old April 19th, 2006, 12:25 AM
Authorized User
 
Join Date: Dec 2005
Location: Bangalore, , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to kapi.goel
Default

file path is not correct means ??

Can u please guide me how to correct it..?




KG
Reply With Quote
  #4 (permalink)  
Old April 19th, 2006, 01:20 AM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Try using the Text attribute of the textbox.
filePath = this.txtAttachFilePath.Text;

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply With Quote
  #5 (permalink)  
Old September 6th, 2007, 03:48 AM
Registered User
 
Join Date: Sep 2007
Location: Bangalore, Karnataka, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Kapil,
Please use server.mappath method to avoid such errors


Sharavanan
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
System.Web.HttpException: Request timed out Ron Howerton General .NET 0 May 21st, 2008 09:23 AM
Mail attachment surendran PHP How-To 0 August 3rd, 2006 07:05 AM
System.Web.Mail - linebreaks possible? RPG SEARCH ASP.NET 1.0 and 1.1 Basics 9 January 29th, 2005 10:54 PM
System.Web.Mail dkb General .NET 3 August 25th, 2004 08:36 AM



All times are GMT -4. The time now is 08:09 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.