Attaching Excel file to Email


#1

Hi All

When attaching an Excel file to an email, I save the file to the HD
ie

excel.Save(“C:\Supercare.xls”, FileFormatType.Default)

but I then get this error

"Access denied because you do not have enough permissions, or another user has the file open and locked."


This on my Dev Machine still, ie I am the only one using my PC, admin rights etc.

What do I need to do ?

Thanks
Neal

#2

Do you run Aspose.Excel in a web application? In a web application, the application runs with Aspnet user context. I think it doesn’t have rights to write file to your driver C.

Please create a temp folder and assign read/write rights to aspnet user.


#3

Hi Laurence

That works now, thanks

However, attaching it to a mail message creates problems.

(using dim mailnew as new mail.message '{SMTP mail from webform’s codebehind)

mailNew.Attachments.Add( System.object)

Any idea what this System.object is?
I have tried an instance of that class as well as System.IO.File

and getting nowhere.

TIA
Neal


#4

Please check MSDN for help.

It’s a System.Web.Mail.MailAttachment object.