473,548 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

smtp.attachment lockes file when send exception.

Hi there,

Im having a bit of trouble with a logfile I use to put logevents in with a
streamwriter, after I have written in this file I want to send the file as a
mailattachment with smtp.
This all works fine until the smtp server goes off line or something goes
wrong.
I'm then catching the 'Mail.Send' exception.

Now there is the problem. The log file I tried to send is now locked so when
the
streamwriter wants to write a line in the file, streamwriter throws me an
exception.
'file is in use by an other process'
the file is now locked and will only unlock when the mail is send (without
exception) or when i kill the app.

Why is it locked, or better, how do I get it unlocked?

Anyone?
//////////////////////////////////////////////////////////////
Try

SmtpMail.SmtpSe rver = SmtpServer

SmtpMail.Send(M yMail)

Catch ex As Exception

' Now the file is
locked

Return ex.Message

End Try
//////////////////////////////////////////////////////////////
Nov 20 '05 #1
1 1399
Cor
Hi Kees,

Why not simple copy the file before you bring it to the Smtp.

Than both processes are independent from each other.

You even can make a test in the making process if the old file is already
processed.

I think that is even as a solution much nicer.

I hope this helps?

Cor
Im having a bit of trouble with a logfile I use to put logevents in with a
streamwriter, after I have written in this file I want to send the file as a mailattachment with smtp.
This all works fine until the smtp server goes off line or something goes
wrong.
I'm then catching the 'Mail.Send' exception.

Now there is the problem. The log file I tried to send is now locked so when the
streamwriter wants to write a line in the file, streamwriter throws me an
exception.
'file is in use by an other process'
the file is now locked and will only unlock when the mail is send (without
exception) or when i kill the app.

Nov 20 '05 #2

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

Similar topics

8
5456
by: marcmc | last post by:
Trying to send an eMail frommy vb.net App. Is there anybody out there that has successfully done this? I am having major problems and need a step by step guide into the world of system.web and IIS. The reading I have done(alot) has been pretty useless in helping me understand the various bits required. The error I get is: On a pc running...
34
18163
by: antonyliu2002 | last post by:
I've set up the virtual smtp server on my IIS 5.1 like so: 1. Assign IP address to "All Unassigned", and listen to port 25. 2. Access Connection granted to "127.0.0.1". 3. Relay only allow "127.0.0.1". 4. Authentication: "Anonymous access" only. 5. Outbound connection listen to TCP 25. Besides,
1
2415
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 e-mail with an attachment. I want to give users an indication of the percentage of the e-mail that has already been sent so as to avoid frustration...
1
2464
by: Chubbly Geezer | last post by:
Hi I am using the following code to send an email from within my program:- MailMessage theMailMessage = new MailMessage("from@email.com", "to@email.com"); theMailMessage.Body = "body email message here"; theMailMessage.Attachments.Add(new Attachment("pathToEmailAttachment")); theMailMessage.Subject = "Subject here"; SmtpClient theClient...
0
1695
by: vermarajeev | last post by:
Hello, I want to send an email via network. My requirement is to send an encrypted file via email. I'm able to send plain text files but if I encrypt and send it, the encrypted file is received but I'm unable to open the file from my application. I get error "incorrect password" though I have entered the correct password. what I did???...
9
3637
by: SREEDEV | last post by:
I am sending a email with a HTML body from my VB.NET application using SMTP protocol. I am facing a problem when i send a long HTML text as body. Its working perfectly with small HTML body. But that same long HTML body mail is working perfectly from a XP server and IIS 5.0. If host the same application in IIS 6.0 and windows 2003 server, this...
5
5078
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi, I'm using this code for sending emails and its working fine because I had configured SMTP in my machine in IIS. now I'm using machine as a server for this application. but when running the same application from other machine the email process is not working. so, do I have to configure and install SMTP in all client machine to get it...
3
1428
by: mturner64 | last post by:
I'm working on a simple web app to send email. Below is my code: Imports System.Net.Mail Partial Class _Default Inherits System.Web.UI.Page Protected Sub SubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitButton.Click Dim FromAddress As String = "mturner64@student.se.edu"
7
16878
by: mukeshrasm | last post by:
Hi I am no able to send mail and it is giving this error Warning: mail(): SMTP server response: 530 5.7.3 Client was not authenticated in c:\inetpub\wwwroot\eshop\includes\classes\email.php on line 522 and the code is: <?php /* $Id: email.php,v 1.12 2003/06/17 17:29:44 dgw_ Exp $
0
7438
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7707
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7951
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7466
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7803
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6036
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5082
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
751
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.