problems with record variable subtype "File&qu
Nagi
Member Posts: 151
Hi,
I'm trying to use a record variable with subtype File to loop through files in a folder and attach these to an e-mail. However, for some reason, the record variable keeps remembering previous files it looped. The result is that it skips files currently in the folder and, when trying to delete files after they've been attached to the e-mail, breaks on error when files doesn't exist.
It's as if the record variable constantly uses "xRec" as a record set. I've tried using CLEAR and CLEARALL, both CLEAR and RESET, etc. without result so far. If you close the application and then reopen it, the record variable will fetch the correct set of files.
The code below is from codeunit Mail.
If any one can help me with this, then I'd be very grateful.
Cheers!
I'm trying to use a record variable with subtype File to loop through files in a folder and attach these to an e-mail. However, for some reason, the record variable keeps remembering previous files it looped. The result is that it skips files currently in the folder and, when trying to delete files after they've been attached to the e-mail, breaks on error when files doesn't exist.
It's as if the record variable constantly uses "xRec" as a record set. I've tried using CLEAR and CLEARALL, both CLEAR and RESET, etc. without result so far. If you close the application and then reopen it, the record variable will fetch the correct set of files.
The code below is from codeunit Mail.
SalesSetup.GET;
SalesSetup.TESTFIELD("Path E-Mail Attachments");
recFile.RESET;
recFile.SETRANGE(Path,SalesSetup."Path E-Mail Attachments");
recFile.SETRANGE("Is a file",TRUE);
IF recFile.FINDSET THEN
REPEAT
BSTRConverterAttachFileName.ResetBSTR;
BSTRConverterAttachFileName.AppendNextStringPortion(recFile.Path + recFile.Name);
OAttachments := OSendMail.Attachments;
OAttachment := OAttachments.Add(BSTRConverterAttachFileName);
ERASE(recFile.Path + recFile.Name);
UNTIL recFile.NEXT = 0;
If any one can help me with this, then I'd be very grateful.
Cheers!
0
Answers
-
Just recently had the same problem.
You should add the following piece of code:recFile.SETRANGE(Path,'c:\'); IF recFile.FINDFIRST THEN;
Just use it instead of the recFile.RESET;.
Like you said. It doesn't do anything..
Tino Ruijs
Microsoft Dynamics NAV specialist0 -
Yes, this is known problem of the File table. Many people are solving that. I think that first post about that was 4 years ago...0
-
Big thanks to tinoruijs! The solution worked perfectly.0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

