473,398 Members | 2,335 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,398 software developers and data experts.

Invalid mail attachment error

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 as an attachment. This all
working fine except that sometimes the code that adds the attachment fires
before the new file is finished being written to, resulting in an "invalid
mail attachment" error.

What is the best way to deal with this? Is there some way to determine if a
file is not being accessed before trying to attach it? Should I find some way
to delay the attachment by a few seconds? Thanks in advance for your help!

Brian
Jul 21 '05 #1
2 1740
Why not just do this in error handling: if the file is being used, sleep for
a second.

--- N

"bmcelhany" <bm*******@discussions.microsoft.com> wrote in message
news:3D**********************************@microsof t.com...
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 as an attachment. This all
working fine except that sometimes the code that adds the attachment fires
before the new file is finished being written to, resulting in an "invalid
mail attachment" error.

What is the best way to deal with this? Is there some way to determine if a file is not being accessed before trying to attach it? Should I find some way to delay the attachment by a few seconds? Thanks in advance for your help!

Brian

Jul 21 '05 #2
That's exactly what I'm thinking, Nick...problem is I'm not sure how to go
about it. I obviously need to create some sort of object (File, FileInfo,
etc.) that has the ability to tell me if the file in question is in use, I
just haven't been able to find something that does that.

"Nick Malik" wrote:
Why not just do this in error handling: if the file is being used, sleep for
a second.

--- N

"bmcelhany" <bm*******@discussions.microsoft.com> wrote in message
news:3D**********************************@microsof t.com...
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 as an attachment. This all
working fine except that sometimes the code that adds the attachment fires
before the new file is finished being written to, resulting in an "invalid
mail attachment" error.

What is the best way to deal with this? Is there some way to determine if

a
file is not being accessed before trying to attach it? Should I find some

way
to delay the attachment by a few seconds? Thanks in advance for your help!

Brian


Jul 21 '05 #3

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

Similar topics

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: 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...
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...
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; ...
5
by: Robert Dufour | last post by:
I am trying to use framework 1.1 - stuck with it. to send emails from a windows form application. The email messages can have attachments, usually two and they can be either text or sounds (wav...
8
by: =?Utf-8?B?cm95SGU=?= | last post by:
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...
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...
2
by: Ruud | last post by:
Just before leaving for a holiday my collegue modified this script. Now it won't send any body text (The data filled in on the form) and in an error condition it won't send any attachments either....
3
by: raj200809 | last post by:
when i m sending mail i received error from symantec Antivirus" Your email message was unable to be sent because your mail server rejected the message 550-5.7.1 the ip you’re using to send mail is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.