How to find Size of an Attachment in RTC

etarunetarun Member Posts: 26
edited 2013-09-04 in NAV Three Tier
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

  • thegunzothegunzo Member Posts: 274
    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.com
  • etarunetarun Member Posts: 26
    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 .
  • ta5ta5 Member Posts: 1,164
    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
  • etarunetarun Member Posts: 26
    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 TK
  • thegunzothegunzo Member Posts: 274
    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.com
  • etarunetarun Member Posts: 26
    Hello

    Thanks for your Help the problem is now solved.

    testfile .. file
        IF  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!
Sign In or Register to comment.