How to deal with spaces in file paths?

VotucVotuc Member Posts: 206
I have a file path that attaches a PDF to an email. NAV does not retrieve the file from the server when I save the file in this folder name - and I suspect it is because of the spaces in the name Old Storage Drive. Because the client computers are already mapped to this location for other reasons, it is not a good idea to change the file folder name.

How can I alter this so that the spaces in "Old Storage Drive" is not a problem?
                    Mail.NewMessage(emailtoaddr,emailccaddr,STRSUBSTNO('Invoice No. %1',SalesInvHeader."No."),
                    'Attached please find invoice ' + SalesInvHeader."No."
                    +'.','\\'+Hostname+'\F$\Old Storage Drive\InvoicePrinter\Invoices\'+STRSUBSTNO
                    ('Invoice No. %1',SalesInvHeader."No.")+'.pdf',TRUE)

Comments

  • reijermolenaarreijermolenaar Member Posts: 256
    Hi Votuc,

    I believe you can replace the spaces with %20.
    Reijer Molenaar
    Object Manager
  • VotucVotuc Member Posts: 206
    Hi Votuc,

    I believe you can replace the spaces with %20.

    This does not seem to work :(
  • reijermolenaarreijermolenaar Member Posts: 256
    Oh sorry, I thought you were making a link in the body and then you have to use %20 or + for spaces to make it one string.

    As attachment location the spaces would not be the problem I think.
    I just tested it and it works.
    Even with a network path.
    Mail.NewMessage('info@test.com', '', 'subject', 'body', '\\l04\c$\Program Files\test test.txt', TRUE);
    
    Reijer Molenaar
    Object Manager
  • VotucVotuc Member Posts: 206
    Thank you for your help. I wonder what is wrong. The file saves perfectly, but does not create the mail attachement. However, if I just save to F:\Invoices (folder I created) then it works perfectly. That led me to think that spaces were the problem.
    //save report as PDF
    REPORT.SAVEASPDF(206, 'F:\Old Storage Drive\InvoicePrinter\Invoices\'+STRSUBSTNO('Invoice No. %1',SalesInvHeader."No.")+'.pdf',
                      SalesInvHeader);
    
    //Create email attachment
                        Mail.NewMessage(emailtoaddr,emailccaddr,STRSUBSTNO('Invoice No. %1',SalesInvHeader."No."),
                        'Attached please find invoice ' + SalesInvHeader."No."
                        +'.','\\'+Hostname+'\F$\Old Storage Drive\InvoicePrinter\Invoices\'+STRSUBSTNO
                        ('Invoice No. %1',SalesInvHeader."No.")+'.pdf',TRUE)
    
  • kinekine Member Posts: 12,562
    in standard cases you need to put the path into "" to prevent splitting on spaces.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.