Microsoft.Navision.Mail.dll locks attachment file

lubost
Member Posts: 633
Hi everyone,
I have developed functionality to send sales documents by SMTP mail as PDF attachments. Everything goes fine, but when I want to delete sent files, Navision locks all sent files and these locks remains till Navision client has been closed. Then are files released and can be deleted (moved).
Environment:
NAV 2009 SP2 classic
Microsoft.Navision.Mail.dll version 7.0.0.0
What's wrong?
Thank you in advance
I have developed functionality to send sales documents by SMTP mail as PDF attachments. Everything goes fine, but when I want to delete sent files, Navision locks all sent files and these locks remains till Navision client has been closed. Then are files released and can be deleted (moved).
Environment:
NAV 2009 SP2 classic
Microsoft.Navision.Mail.dll version 7.0.0.0
What's wrong?
Thank you in advance
0
Comments
-
Try putting a SLEEP(x) after the Send command to give NAV some time to send the mail and release the attachment. If you are always using the same filenames for your attachments, you can also delete them prior of creating them to get rid of the old ones.No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0
-
Thank you for your response.
Files has unique filenames and are locked a hours ... exactly till Navision client has been closed.0 -
Are they saved in the TEMPORARYPATH folder?No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0
-
No, they are saved in "normal" path and till sending they are freely accesed (delete, move). But exactly attaching (or) sending file as attachment causes lock. Piece of code:
Mail.SetHTMLBody(TRUE);
Mail.AddAttachment(DocQueue."Document No." + '.PDF',
CompanyInfo."Signed Folder" + DocQueue."Document No." + '_signed.pdf');
WITH SMTPMailSetup DO
Mail.SetConnectionParameters("SMTP Server", "SMTP Server Port", FALSE, TRUE, "User ID", Password);
Result := Mail.SendMail();
and mails are sent correctly, wihout any error.0 -
That is a problem with Navision Mail version 7.0, you need to get the version 7.1 or 7.3 where there is a new method (Dispose) to free the atttachment after use the method Send.
Regards,0 -
Can you please drop a link where I can download these versions from?
Thank you in advance0 -
https://www.dropbox.com/s/ijsx07ymeg5g2 ... l.zip?dl=0
You need to extract the files where are the previous version and execute the bat (register_for_com) as Adminstrator.
You need to check the parameters in the Send method because they have changed from version 7.0.
And add the method Dispose after Send in codeunit 400.
Regards0 -
Thank you ... DLL works as expected.0
-
DLL doesn't locks attachments files but it uses domain authorization to send a mail withou respect to Send method parameters. I want to use this DLL to send PDFs by Navision Application Server (which need to run as domain user) and mailserver rejected message due to domain restrictions. SMTP setting is anonymous a all works fine in case of database login.
I tried to manipulate with SMTP setting, but Anonymous, NTLM, Basic setting hasn't any effect with windows login.
What's wrong?0 -
That works for sure.
Verify that the user that starts the NAS have the rights to send mail in your Mail Server.
Regards.0 -
Thank you for your reply.
I don't want to send mail as user who starts NAS. I want DLL to use permission saved in SMTP Setup table. It seems that DLL uses domain permissions of logged user and don't use parametersfrom calling trigger:
WITH SMTPMailSetup DO
Mail.SetConnectionParameters("SMTP Server", "SMTP Server Port", FALSE, TRUE, "User ID", Password);
I tried play with FALSE/TRUE parameters, but nothing changed.0 -
Can you explain how you call to the DLL Send method, because the line below doesn't look like any method of this DLL ?
>>>> Mail.SetConnectionParameters("SMTP Server", "SMTP Server Port", FALSE, TRUE, "User ID", Password);
In version 7.3 this is the way:
Mail.Send("SMTP Server", "SMTP Server Port", TRUE, "User ID", Password, FALSE);
The TRUE is for authentication and the FALSE for enableSSL, this last can be changed if you uses SSL along with the Server Port.
And you need to verify if your SMTP Mail Server allows that conection (user/password). You can use Outlook to configure the account and check it.0 -
Thank you for reply.
As I said, I played with FALSE/TRUE settings, but in all cases DLL uses the credentials of logged user (windows login) and never uses "User ID" and Password from SMTP setup.
With version 7.3 of DLL I actually use the following approach:
WITH SMTPMailSetup DO
Result := Mail.Send("SMTP Server", "SMTP Server Port", Authentication = Authentication::NTLM, "User ID", Password, FALSE);
but with Authentication set to Anonymous, NTLM or Basic - result is same - DLL logs to mail server with <domain>\<user> credentials.0 -
So, I think that you must test your SMTP Mail Server with Outlook to verify if is possible to connect with that user/password combination, if that is the case then you can use the same with Authentication = Basic and the DLL.
I tell you that because I'm using this in several installations and it's working without any problem.
Regards0 -
Thank you for your reply.
We tested connection with manual request to send and all works fine, but we used database login during these tests. When we moved functionality under NAS (windows login), we discovered that DLL uses this login whatever SMTP setting. Connection is established and email are sent, but customer wants to disallow windows credentials to mail server (remote, provider based).
Another problem is body encoding. Body is a HTML and this mail DLL uses UTF-16 encoding and on some mail servers/clients is content broken. Is the way to set encoding of HTML mail body?0 -
You can use a remote provider with NAS, e.g. GMAIL or Office365 with the port 587 and SSL = TRUE and that work for sure, regarding the HTML body I don't think we have any control on this with the DLL.
You can try 'Microsoft CDO for Windows 2000 Library'.Message and 'Microsoft CDO for Windows 2000 Library'.Configuration instead of the Navision Mail DLL.
Regards.0 -
Hello @Berno_S ,
Yes, I have the Navision Mail 7.3, here is the link with two 7.3 versions one newer than the other:
https://www.dropbox.com/s/1cb1x4pqdp17zag/Mail_Dynamics_NAV2009R2_V7.3.zip?dl=1
Regards0 -
This is all done, the error comes on executning the to statement
Btw I renamed the old variable to mail2, so it's the new variable i'm using0 -
Hello @Berno_S ,
The 7.3 version works, the error seems strange, maybe it is a conflict with the previous version.
Try to install in a clean environment.
Regards.
Sorry for the late reply, but had to leave the assignment for some time for other projects, but now I got the server restarted and reregistered the new dll.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