Click here to Skip to main content
15,888,315 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey guys, I'm just using some normal SMTP emailing code and I'm adding an attachment to send. Besides its extremely slow sending time (Around 4 minuets(I had to turn off the deadswitch and turn time out to 30 min)), it also seems to lock the file from being written to. I can no longer append to the file.

Any help? I'm attaching two files, one is less than a megabyte while the second one would be around 10 megabytes.
Posted
Comments
Yusuf 7-Aug-10 0:37am    
That is unusual, show us the code so we may spot something

You have to wait for SMTP to finish sending the email and its attachment.
After that you should Dispose the MailMessage object and then the attachment is unlocked.

So:
SmtpClient oSmtp = new SmtpClient();
//set properties
MailMessage oMail = new MailMessage();
//set properties
oSmtp.Send(oMail);
oMail.Dispose();


This worked for me just fine.
 
Share this answer
 
Comments
Mike$7 7-Aug-10 11:15am    
I've done that but the file is still locked... or at least my program can't write to it, although no exceptions pop up...
Yeah, that happens. It's happened to me, too. I suggest you make a copy of the file in order to mail it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900