Hello All,
Can anybody suggest me how can i find the size of an Attachment before sending it as an E-mail.
The problem is that the code works fine in Classic Client.
Here in Classic Client i check the size of the file if its greater than 1 MB then i make file name blank. And later files not having names are not sended.
But this code does not work in RTC. RTC still tries to send the file. What shall i do
lrecFile : Rec... File
lfilename : Text ..1024
IF lrecFile.FINDFIRST THEN
BEGIN
IF (lrecFile.Size /1000000) > 1 THEN
BEGIN
lfilename := '';
END;
END;
Thanks in Advance
TK
Answers
The lrecFile variable will look for the file on the server but not on the client.
Look at codeunit 419 to see how to access the local filesystem.
Gunnar Gestsson
Microsoft Certified IT Professional
Dynamics NAV MVP
http://www.dynamics.is
http://Objects4NAV.com
The File is on Server, but that does not make any difference. System works fine until we try to send the file as an Email.
The problem is that RTC still tries to send the file though its greater than the permitted mail server range.
In Classic Client by the above mentioned code we check the size and stop the file there itself .
Another method is to use "'Microsoft Scripting Runtime'.FileSystemObject" as Automation object. In the create() function you decide whether the object is created on Server or on Client, hence you decide what files you want to see. Hope this helps.
Thomas
Hi Thomas,
Thanks for you Time and pointing me to a direction, It is a bit close but not exactly what i was looking for . "'Microsoft Scripting Runtime'.FileSystemObject" does not provide me anyway to find the size of the file but "'Microsoft Scripting Runtime'.File" does give me an option of file size. Let me check that and will get back if it does not work.
Thanks TK
As I said, in codeunit 419 Microsoft uses DotNet variable System.IO.File from mscorlib.
If you use System.IO.FileInfo then you can use a property Length to give you the file size.
Gunnar Gestsson
Microsoft Certified IT Professional
Dynamics NAV MVP
http://www.dynamics.is
http://Objects4NAV.com
Thanks for your Help the problem is now solved.
testfile .. file did the trick
Then the file was stored locally on the Server where the Servicetier was running.
Checking for the session on Servicetier.
If Session was True then saving the file on Server with servicetier.
Thanks TK!