How to find Size of an Attachment in RTC

etarun
Member Posts: 26
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
Thanks in Advance
TK
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
0
Answers
-
Hi
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.com0 -
thegunzo wrote:Hi
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.
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 .0 -
Hi
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.
Thomas0 -
ta5 wrote:Hi
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 TK0 -
If you are using NAV 2013 then the automation is not an option for the server.
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.com0 -
Hello
Thanks for your Help the problem is now solved.
testfile .. fileIF ISSERVICETIER THEN BEGIN testfile.OPEN(lfilename); IF (testfile.LEN / 1000000 ) > 1 THEN BEGIN lfilename := '' ; END;
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!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions