473,326 Members | 2,680 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,326 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 1738
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: 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...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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...
1
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...
1
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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.