12-05-2011 12:32 AM
Hi,
I need some help. I am creating a file called Appl5, write some thing to it and close it. Then, I am opening the same file, read the content and use that content as an email body. and at the same time use that file as an email attachement. and then send my email and finally delete the file.
the problem is here:
- after reading the file, and when trying to use it as the body of the email that will be sent, the body of my email doesn't have that content, just maybe a letter, or 1 charcter.
- I am not able to delete the file
could someone take a look?
thank you.
Solved! Go to Solution.
12-05-2011 08:20 AM
Agyna,
As far as I can see, you are trying to do things in parallel, just make sure you wire error outputs to ensure data flow. There is no guarantee that your file creation section will execute first as it stands. I have wired couple of error clusters, I haven't tested it so there may be other things wrong with it. Also, the diagram is quite large right now, try to break it down to subvi's for better readability.
Hope this is what your problem is.
Regards,
aCe
12-05-2011 08:31 AM
Also:
12-05-2011 12:53 PM
Thanks for replying, but I still cannot delete the file at the end.
also the body of the email doesn't contain the content of what is read from the file.
more help needed!
Thanks.
12-05-2011 01:22 PM - edited 12-05-2011 01:28 PM
I see you have the simple error handler at the end which is good. An error in to the delete file function will prevent it from deleting the file. Are you presented with any errors after this vi is run?
It looks like you are using gmail. Could it be related to gmail? Any chance you can try it with a different mail server?
You have a comparison of an empty string going to a case selector for an attachment. This iwll always be true because of the constant wired to the path to string. I realize the constant is there for debugging but there is a function "Not a Number/Path/Refnum?" which is better to use. In fact you could use the Check if File or Folder Exists vi to select the case.
12-05-2011 03:03 PM
Yes, I am getting error 5. No this is not related to gmail. If you place the delete block right after the cc, add case, it works fine. So as you said the problem is coming from the case selector for the attachment part. So I use "check if file exist" and I deleted the case selector part, it is still giving me error 5, and cannot delete the file.
12-06-2011 07:00 AM
I don't have LabVIEW right now so I have to try to remember your vi. I remember that you write to a file then close it, do some .NET email stuff, then delete the file.
Error 5 will happen if you try to delete a file that is already open. Although you closed it after writing to it, the .NET file attachment methods may be keeping the file open. Are you calling the dispose method after the file attachment method?
12-06-2011 07:13 AM
Hi!
Create a state-machine or use the error-wire properly to ensure dataflow, as suggested earlier. Close the reference to the file before deleteing it. Like Steve says, the file might be in use by the .Net nodes.
12-06-2011 07:39 AM
As I said I am going by memory right now and I only took a brief look at the vi. I don't remember any obvious dataflow issues but that could definately cause problems. State machines are good but in this case it might be overkill. (Again, going by possibly faulty memory)
12-06-2011 11:13 AM
You could also try putting a Wait before the Delete. You might not be giving .NET a chance to do its thing.