Options

File path is breaking

kmkaotkmkaot Member Posts: 261
I want a create PDF file,
    with local path. file path was stored in a SMTP table.
  1. saved file using save as pdf function
  2. when I want attach the file
  3. name is breking into line like d:\temp\invoice.pdf like
  4. D:
  5. temp
  6. Invoice.pdf

    Please help me how to retrive file from path

    Warm regards
    Krsh

Answers

  • Options
    KishormKishorm Member Posts: 921
    To retrieve the filename only you can keep stripping of everything upto the next slash, something like this...
    FileName := FilePathAndName;
    WHILE STRPOS(FileName,'\') > 0 DO
      FileName := COPYSTR(FileName, STRPOS(FileName,'\') +1);
    
  • Options
    kmkaotkmkaot Member Posts: 261
    Thanks
    Actually I want my file name should be for example 'D:\temp\invoice.pdf'
    not
    like this
    d:
    Temp
    Invoice.pdf

    Please help me,

    Kris
  • Options
    KishormKishorm Member Posts: 921
    That is only splitting when you display it using MESSAGE or ERROR because the backslash character is being interpreted as a new line. In order to work around this you could convert it to a forward slash when displaying it, e.g.
    MESSAGE(CONVERTSTR(FileAndPathName,'\','/'));
    
  • Options
    kmkaotkmkaot Member Posts: 261


    SMTPsetup.GET;
    SenderName:=SMTPsetup."Email sender Name";
    SenderAddress:=SMTPsetup."Email sender email";
    Recipients:=vendorRec."E-Mail"+';'+SMTPsetup."Manager Email";

    kSubject:="No."+' PO for '+FORMAT(Amount);
    kBody:=' ';
    Tofile := Name;
    Tofile := "No."+'.pdf';


    FileName := SMTPsetup."Path to Save Report" + Tofile;
    FileName := CONVERTSTR(FileName,'/','\');
    MESSAGE(CONVERTSTR(FileName,'/','\'));


    CurrPage.SETSELECTIONFILTER(Rec);
    REPORT.SAVEASPDF(405, FileName, Rec);

    CLEAR(email);
    email.CreateMessage(Recipients,'','',kSubject,kBody,FALSE,FALSE);
    email.AddBodyline(' Dear Sir/Madam');
    email.AddBodyline('<BR><BR>');
    email.AddBodyline(' PO Document '+"No."+' '+"Pay-to Name"+' approved ');
    email.AddBodyline('<BR><BR>');
    email.AddBodyline('Operations');
    email.AddBodyline('<BR><BR>');
    email.AddBodyline('Shura');
    email.AttachFile(FileName);
    email.Send();
  • Options
    KishormKishorm Member Posts: 921
    You have the slash and backslash the wrong way round in your message - see my previous post
  • Options
    kmkaotkmkaot Member Posts: 261
    file path works only with back slash '\' not '/'.

    i am i right?
  • Options
    KishormKishorm Member Posts: 921
    edited 2017-01-18
    I think it might work with either (even though traditionally it's been \ from the good old DOS days :) ). Give it a try.

    For displaying in a message though, it doesn't really matter I would have thought.
  • Options
    vaprogvaprog Member Posts: 1,118
    kmkaot wrote: »
    file path works only with back slash '\' not '/'.

    i am i right?

    No! Windows handles forward slashes just all right as path separators in file paths. Many programs do not, though. On the command line, you need to quote a path containing forward slashes, because the forward slash is the traditional option start character on DOS/Windows command lines.

    Back to NAV: For a MESSAGE command to display a file path properly, use value substitution:
    MESSAGE('%1',FileName);
    
    Backslashes in the String parameter get converted to Newlines, backslashes in the Valuen parameters are preserved. (See link above.)

    With appending the file to the eMail message, I did not have any issue. No conversion needs to be done. It won't hurt, though, because of what I said in the beginning.
Sign In or Register to comment.