Hi Winan,
You will need to grant rights for the ASPNET user to the directory where the attachment files are stored. Your problem sounds like it is a security issue.
>I used below codes for sending email thru asp.net, everything goes ok if I send email without file attachment.. and I will met error "Invalid mail attachment" If file attached ..am I missing something inside the codes? ..
>could any body please help me ? .. many thanks in advance
>
>Imports System.Web.Mail
>Public Sub SendEmail(ByVal pTo As String, ByVal pSubject As String, ByVal pBody As String, ByVal pAttachment As String)
>Dim objMail
>Dim mailMessage As New MailMessage()
>Dim mFrom As String
>Dim mSMTPServer As String
>mSMTPServer = ConfigurationSettings.AppSettings("mSMTPServerName")
>mFrom = ConfigurationSettings.AppSettings("mFromForgotPassword")
>If Len(Trim(mSMTPServer)) > 0 And Len(Trim(mFrom)) > 0 Then
>mailMessage.From = mFrom
>mailMessage.To = pTo
>mailMessage.Subject = pSubject
>mailMessage.BodyFormat = Mail.MailFormat.Text
>mailMessage.Body = pBody
>If Len(Trim(pAttachment)) > 0 Then
>Dim mAttachment As New MailAttachment("C:\WINAN1.TXT")
>mailMessage.Attachments.Add(mAttachment)
>End If
>SmtpMail.SmtpServer = mSMTPServer
>SmtpMail.Send(mailMessage)
>End If
>End Sub
>
>
>Regards
>Winan
-----------------------------------------
Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.comwww.prenia.comWeblog: blogs.prenia.com/cathi