Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 18th, 2006, 06:47 AM
Authorized User
 
Join Date: Dec 2005
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
 
Old April 18th, 2006, 11:05 AM
Authorized User
 
Join Date: Apr 2006
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'

 
Old April 18th, 2006, 11:25 PM
Authorized User
 
Join Date: Dec 2005
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
 
Old April 19th, 2006, 12:20 AM
Friend of Wrox
 
Join Date: Jun 2003
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.
======================================
 
Old September 6th, 2007, 02:48 AM
Registered User
 
Join Date: Sep 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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


Sharavanan





Similar Threads
Thread Thread Starter Forum Replies Last Post
System.Web.HttpException: Request timed out Ron Howerton General .NET 0 May 21st, 2008 08:23 AM
Mail attachment surendran PHP How-To 0 August 3rd, 2006 06: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 07:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.