473,320 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Invalid mail attachment

I have a web service. It creates a email and attached a file sitting one the
network drive \\servername\filename. I tried UNC format and also try to
mapping drive (eg. g:\text.txt or g:\\text.txt). I also check the permission
of the file and file sharing (grant to everyone), I still got the following
err:

Server was unable to process request. --Invalid mail attachment
'g:\\g:\\text.txt)'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Here is the code:

Dim mailMessage As New System.Web.Mail.MailMessage
Dim emailAttachment As New System.Web.Mail.MailAttachment
mailMessage.To = strSubmissionEmailAddress
mailMessage.Cc = "ab*@abc.com"
mailMessage.From = "ab*@aaa.com"
mailMessage.Subject = "test"
mailMessage.BodyFormat = System.Web.Mail.MailFormat.Text
mailMessage.Body = pStrMessageBody
mailMessage.Attachments.Add(emailAttachment)

SmtpMail.SmtpServer = strSubmissionSmtpServer
SmtpMail.Send(mailMessage)
Please help! Thank you!
Feb 6 '07 #1
8 5212
By the way, do I have to upload the file to the server and attached the file
locally? or I can attach file from network drive?
"royHe" wrote:
I have a web service. It creates a email and attached a file sitting one the
network drive \\servername\filename. I tried UNC format and also try to
mapping drive (eg. g:\text.txt or g:\\text.txt). I also check the permission
of the file and file sharing (grant to everyone), I still got the following
err:

Server was unable to process request. --Invalid mail attachment
'g:\\g:\\text.txt)'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Here is the code:

Dim mailMessage As New System.Web.Mail.MailMessage
Dim emailAttachment As New System.Web.Mail.MailAttachment
mailMessage.To = strSubmissionEmailAddress
mailMessage.Cc = "ab*@abc.com"
mailMessage.From = "ab*@aaa.com"
mailMessage.Subject = "test"
mailMessage.BodyFormat = System.Web.Mail.MailFormat.Text
mailMessage.Body = pStrMessageBody
mailMessage.Attachments.Add(emailAttachment)

SmtpMail.SmtpServer = strSubmissionSmtpServer
SmtpMail.Send(mailMessage)
Please help! Thank you!
Feb 6 '07 #2
By the way, do I have to upload the file to the server and attached
the file locally? or I can attach file from network drive?
Well, if the server has access to the file - then you might consider to
leave all execution at the server.
>Please review the stack trace for more information about the error
and where it originated in the code.
Can you give us the stack trace? Because the error can be manifold:
- SecurityException -No access to the File
- File Not Found Exception -Attachement file not found
- Some other coding error, nothing to do with the mail sending, but
causing the error.

However, from the main message, I believe that the path is wrongly
interpreted. Have you also tried the @ before the string?
@"G:\test.txt"?

.... waiting for your feedback
Markus
Feb 6 '07 #3
Here is the trace:
Server was unable to process request. --Invalid mail attachment
'g:\\BVAN025'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Web.Services.Protocols.SoapException: Server was
unable to process request. --Invalid mail attachment 'g:\\BVAN025'.

Source Error:
Line 148:
<System.Web.Services.Protocols.SoapDocumentMethodA ttribute("http://tempuri.org/SubmitEFTFileByMail",
RequestNamespace:="http://tempuri.org/",
ResponseNamespace:="http://tempuri.org/",
Use:=System.Web.Services.Description.SoapBindingUs e.Literal,
ParameterStyle:=System.Web.Services.Protocols.Soap ParameterStyle.Wrapped) _
Line 149: Public Function SubmitEFTFileByMail(ByVal pStrMessageBody
As String, ByVal pStrAttachment As String) As String
Line 150: Dim results() As Object =
Me.Invoke("SubmitEFTFileByMail", New Object() {pStrMessageBody,
pStrAttachment})
Line 151: Return CType(results(0),String)
Line 152: End Function
Source File: C:\VEHICLERENTALSYSTEM\Web\Web
References\EFTService\Reference.vb Line: 150

Stack Trace:
[SoapException: Server was unable to process request. --Invalid mail
attachment 'g:\\BVAN025'.]

System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
methodName, Object[] parameters)
EFTService.AirMilesEFTService.SubmitEFTFileByMail( String pStrMessageBody,
String pStrAttachment) in C:\VEHICLERENTALSYSTEM\Web\Web
References\EFTService\Reference.vb:150
WebForm1.Page_Load(Object sender, EventArgs e) in
C:\VEHICLERENTALSYSTEM\Web\WebForm1.aspx.vb:35
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()


"Markus" wrote:
By the way, do I have to upload the file to the server and attached
the file locally? or I can attach file from network drive?

Well, if the server has access to the file - then you might consider to
leave all execution at the server.
Please review the stack trace for more information about the error
and where it originated in the code.

Can you give us the stack trace? Because the error can be manifold:
- SecurityException -No access to the File
- File Not Found Exception -Attachement file not found
- Some other coding error, nothing to do with the mail sending, but
causing the error.

However, from the main message, I believe that the path is wrongly
interpreted. Have you also tried the @ before the string?
@"G:\test.txt"?

.... waiting for your feedback
Markus
Feb 6 '07 #4
When I copy the file to the server where the web service is running, then it
works fine. I am just wondering the file could not be in the network drive.
It has to be in the local drive. Is this true?

Thanks

"royHe" wrote:
I have a web service. It creates a email and attached a file sitting one the
network drive \\servername\filename. I tried UNC format and also try to
mapping drive (eg. g:\text.txt or g:\\text.txt). I also check the permission
of the file and file sharing (grant to everyone), I still got the following
err:

Server was unable to process request. --Invalid mail attachment
'g:\\g:\\text.txt)'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Here is the code:

Dim mailMessage As New System.Web.Mail.MailMessage
Dim emailAttachment As New System.Web.Mail.MailAttachment
mailMessage.To = strSubmissionEmailAddress
mailMessage.Cc = "ab*@abc.com"
mailMessage.From = "ab*@aaa.com"
mailMessage.Subject = "test"
mailMessage.BodyFormat = System.Web.Mail.MailFormat.Text
mailMessage.Body = pStrMessageBody
mailMessage.Attachments.Add(emailAttachment)

SmtpMail.SmtpServer = strSubmissionSmtpServer
SmtpMail.Send(mailMessage)
Please help! Thank you!
Feb 6 '07 #5
When I copy the file to the server where the web service is running,
then it works fine. I am just wondering the file could not be in the
network drive. It has to be in the local drive. Is this true?
I checked your stack-trace and cannot tell you the solution.

However, I am pretty sure, there are some security/permissions to
consider, because I had also a similar problem a few years ago, but
can't remember, how to resolve it.

But just to get you some ideas: The web service is run under the IIS web
account (or whatever account you have configured). This user must have
permissions to access the remote location. There might be some
additional issues, if you are working in an Active Directory environment...

To check it, try to access the file via code and wrap a try/catch block
around it. Then check the exception in the debugger just to be sure, if
it is really a SecurityException.

try
{
ReadFile();
}
catch (Exception ex)
{
// debug into this line
}

sorry for running out of ideas right now and not being able to help you
out...

Markus
Feb 6 '07 #6
My understanding is:
Webmail is running under IIS, so it has no permission to access network file
system.

Let me know if my understanding is wrong.

Thanks

"royHe" wrote:
When I copy the file to the server where the web service is running, then it
works fine. I am just wondering the file could not be in the network drive.
It has to be in the local drive. Is this true?

Thanks

"royHe" wrote:
I have a web service. It creates a email and attached a file sitting one the
network drive \\servername\filename. I tried UNC format and also try to
mapping drive (eg. g:\text.txt or g:\\text.txt). I also check the permission
of the file and file sharing (grant to everyone), I still got the following
err:

Server was unable to process request. --Invalid mail attachment
'g:\\g:\\text.txt)'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Here is the code:

Dim mailMessage As New System.Web.Mail.MailMessage
Dim emailAttachment As New System.Web.Mail.MailAttachment
mailMessage.To = strSubmissionEmailAddress
mailMessage.Cc = "ab*@abc.com"
mailMessage.From = "ab*@aaa.com"
mailMessage.Subject = "test"
mailMessage.BodyFormat = System.Web.Mail.MailFormat.Text
mailMessage.Body = pStrMessageBody
mailMessage.Attachments.Add(emailAttachment)

SmtpMail.SmtpServer = strSubmissionSmtpServer
SmtpMail.Send(mailMessage)
Please help! Thank you!
Feb 6 '07 #7
My understanding is: Webmail is running under IIS, so it has no
permission to access network file system.
I don't know, what you mean with Webmail - but if you mean anything,
that is running as a website or webservice, then you are right (at least
for the default settings).

However, for testing, you can configure IIS to run under Administrator
rights (bad for production usage, but good for testing). Then, if this
is working, you might consider to setup a user with permissions to the
remote file system.

Additionally, keep in mind that network-drive mappings are user
specific. So just because you have mounted \\server\share1 as G: it does
not mean that the IIS user also has the G: mounted. So you might want to
use the \\server\share1 notation instead of drive mapping.

.... however, I am starting to talk to much guesswork, as I am out of the
web business already a couple of years right now... so you might find a
better answer by searching the internet for "asp.net access file share"
or something similar...

Hope, I could give you at least some ideas.
Markus
Feb 6 '07 #8
Hi Markus,
Thank you for your help.

I think it is quite helpful. I acutually realize the issue, I just want to
confirm. After testing, I will let you know exact.

Thanks

"Markus" wrote:
My understanding is: Webmail is running under IIS, so it has no
permission to access network file system.

I don't know, what you mean with Webmail - but if you mean anything,
that is running as a website or webservice, then you are right (at least
for the default settings).

However, for testing, you can configure IIS to run under Administrator
rights (bad for production usage, but good for testing). Then, if this
is working, you might consider to setup a user with permissions to the
remote file system.

Additionally, keep in mind that network-drive mappings are user
specific. So just because you have mounted \\server\share1 as G: it does
not mean that the IIS user also has the G: mounted. So you might want to
use the \\server\share1 notation instead of drive mapping.

.... however, I am starting to talk to much guesswork, as I am out of the
web business already a couple of years right now... so you might find a
better answer by searching the internet for "asp.net access file share"
or something similar...

Hope, I could give you at least some ideas.
Markus
Feb 6 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: PeterR | last post by:
I've spent weeks trying to write a function that is simple to use for sending emails with attachments, but I my programming skills are not that advanced. I've noticed a few postings in these...
0
by: imre.adam | last post by:
The original message was received at Wed, 2 Mar 2005 20:06:59 +0100 from 87.26.243.56 ----- The following addresses had permanent fatal errors ----- <python-list@python.org> ----- Transcript...
1
by: Fraser S | last post by:
Hi, I am receiving an invalid mail Attachment error when trying to send an attachment using System.Web.Mail. I have read other posts on these errors and have since checked that the asp.net account...
2
by: bmcelhany | last post by:
Hello, I'm developing a windows service that monitors a directory (using a FileSystemWatcher) for newly created files. When a new file is created, I need to generate an e-mail and send that file...
2
by: GD | last post by:
Hi, An intranet application, with a SMTP mail function that lets users to attach files with emails by selecting files in their local computers (through a file browser component), works perfect on...
4
by: Reticulated Ember | last post by:
I have the following code that fails with an invalid cast exception: .... System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage(); msg.BodyFormat = MailFormat.Html; ...
1
by: theWizard1 | last post by:
The following sends my email, but the attachment is empty. The attachment should contain the data that is in the string that was created from the xmlReader. I have a stored procedure written...
1
by: William Connery | last post by:
Hi, I have a small python program with e-mail capabilities that I have pieced together from code snippets found on the internet. The program uses the smtplib module to successfully send an...
0
by: Kirsten Kleist | last post by:
I have an application that creates several .csv files in a directory on the user's hard drive and then sends an email with the same .csv files as attachments. One of the users is getting an error...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.