Problems calling SMTP CodeUnit 400 from NAV2009 service tier

blusky75
Member Posts: 22
Has anyone had any success sending an email from the NAV 2009 service tier via code unit 400?
We've already identified that ENVIRON() is obselete and that alone would need updating wherever ENVIRON() is called in that code. Now we cannot create an instance of the 'Microsoft Navision Mail'.SmtpMessage
Here's our situation:
We have a .NET application that consumes various page & codeunit webservices exposed in NAV. One of those codeunits has a function that, when called, updates various tables in NAV. One of those table fields has a trigger to launch an email via code unit 400.
Since the code unit is run on the service tier because the web services are involved, the Microsoft.Navision.Mail.dll needs to be installed & registered on that service tier. Correct?
We've done just that. There are plenty of threads here outlining that and included both the /tlb:Microsoft.Navision.Mail.tlb and /codebase switches when executingthe .net 2.0 regasm utility.
Regasm reports that the registrations were successful. However, when our .net application calls the NAV web service, the service tier will try to send an email but it complains with the following message (below was captured from the service tier's windows application event log) when it tries to create an instance of the 'Microsoft Navision Mail'.SmtpMessage global variable in code unit 400:
This message is for C/AL programmers: Unable to create an instance of Automation Server System.__ComObject with CLSID = f9dae2a4-d2f8-37c3-86d5-e4ffe166d860 Retrieving the COM class factory for component with CLSID {F9DAE2A4-D2F8-37C3-86D5-E4FFE166D860} failed due to the following error: 80040154..
StackTrace:
at Microsoft.Dynamics.Nav.Runtime.NavAutomation.Create()
at Microsoft.Dynamics.Nav.Runtime.NavAutomation.Create(DataError errorLevel, Boolean newServer, Boolean clientSide)
at Microsoft.Dynamics.Nav.Runtime.NavAutomation.Create(DataError errorLevel)
at Microsoft.Dynamics.Nav.BusinessApplication.Codeunit400.CreateMessage(NavText senderName, NavText senderAddress, NavText recipients, NavText subject, NavText body, Boolean htmlFormatted) in c:\ProgramData\Microsoft\Microsoft Dynamics NAV\60\Server\MicrosoftDynamicsNavServer\source\Codeunit\Codeunit400.cs:line 210
at Microsoft.Dynamics.Nav.BusinessApplication.Codeunit400.OnInvoke(Int32 memberId, Object[] args) in c:\ProgramData\Microsoft\Microsoft Dynamics NAV\60\Server\MicrosoftDynamicsNavServer\source\Codeunit\Codeunit400.cs
The service tier is running Windows 64 bit, and the Microsoft.Navision.Mail.dll was registered via regasm in the C:\Program Files (x86)\Common Files\Microsoft Dynamics NAV\Mail. I've seen other threads (relating to NAS) to copy those DLLs to the service NAS's application folder. We've done the equivalent (in our case, the service tier app directory is in C:\Program Files (x86)\Microsoft Dynamics NAV\60\Service), but no luck. Every single time the service tier executes code unit 400, it cannot create an instance of COM CLSID {F9DAE2A4-D2F8-37C3-86D5-E4FFE166D860}
Any help would be greatly appreciated
We've already identified that ENVIRON() is obselete and that alone would need updating wherever ENVIRON() is called in that code. Now we cannot create an instance of the 'Microsoft Navision Mail'.SmtpMessage
Here's our situation:
We have a .NET application that consumes various page & codeunit webservices exposed in NAV. One of those codeunits has a function that, when called, updates various tables in NAV. One of those table fields has a trigger to launch an email via code unit 400.
Since the code unit is run on the service tier because the web services are involved, the Microsoft.Navision.Mail.dll needs to be installed & registered on that service tier. Correct?
We've done just that. There are plenty of threads here outlining that and included both the /tlb:Microsoft.Navision.Mail.tlb and /codebase switches when executingthe .net 2.0 regasm utility.
Regasm reports that the registrations were successful. However, when our .net application calls the NAV web service, the service tier will try to send an email but it complains with the following message (below was captured from the service tier's windows application event log) when it tries to create an instance of the 'Microsoft Navision Mail'.SmtpMessage global variable in code unit 400:
This message is for C/AL programmers: Unable to create an instance of Automation Server System.__ComObject with CLSID = f9dae2a4-d2f8-37c3-86d5-e4ffe166d860 Retrieving the COM class factory for component with CLSID {F9DAE2A4-D2F8-37C3-86D5-E4FFE166D860} failed due to the following error: 80040154..
StackTrace:
at Microsoft.Dynamics.Nav.Runtime.NavAutomation.Create()
at Microsoft.Dynamics.Nav.Runtime.NavAutomation.Create(DataError errorLevel, Boolean newServer, Boolean clientSide)
at Microsoft.Dynamics.Nav.Runtime.NavAutomation.Create(DataError errorLevel)
at Microsoft.Dynamics.Nav.BusinessApplication.Codeunit400.CreateMessage(NavText senderName, NavText senderAddress, NavText recipients, NavText subject, NavText body, Boolean htmlFormatted) in c:\ProgramData\Microsoft\Microsoft Dynamics NAV\60\Server\MicrosoftDynamicsNavServer\source\Codeunit\Codeunit400.cs:line 210
at Microsoft.Dynamics.Nav.BusinessApplication.Codeunit400.OnInvoke(Int32 memberId, Object[] args) in c:\ProgramData\Microsoft\Microsoft Dynamics NAV\60\Server\MicrosoftDynamicsNavServer\source\Codeunit\Codeunit400.cs
The service tier is running Windows 64 bit, and the Microsoft.Navision.Mail.dll was registered via regasm in the C:\Program Files (x86)\Common Files\Microsoft Dynamics NAV\Mail. I've seen other threads (relating to NAS) to copy those DLLs to the service NAS's application folder. We've done the equivalent (in our case, the service tier app directory is in C:\Program Files (x86)\Microsoft Dynamics NAV\60\Service), but no luck. Every single time the service tier executes code unit 400, it cannot create an instance of COM CLSID {F9DAE2A4-D2F8-37C3-86D5-E4FFE166D860}
Any help would be greatly appreciated
0
Comments
-
Did you instantiate the com object from within the Nav code correctly?
Using the IsServiceTier switch to use the correct parameters in the Create function call?
In the Online guide is does not show the extra parameter, but if you use the C/AL Symbol menu it does.
Here the comparison of both... you need the new switch <ClientSide>
t0 -
What the heck, I just realized Seven years to get to my 100th post..... here it is.
t0 -
Thanks for the reply. We've made no modifications to Code Unit 400 (it has a NAVW15.00.01 version tag attached to it)
But looking at Code unit 400's createmessage() function, the code to instantiate the smtp mail automation object is as follows:
IF ISCLEAR(Mail) THEN
CREATE(Mail);
You are correct, that the second undocumented parameter is missing. However, isn't that param solely for role tailored clients? In the situation where a web service is used to send the email, there is no client to instantiate the COM object.
That said, is there any way to run code unit 400 from the service tier? If not, I'm worried that we'll have to roll our own SMTP solution.0 -
the code is fine and it works fine on service tier. Your problem is that you are trying to run it in 64 bit OS.
Take a look at this thread
http://social.msdn.microsoft.com/Forums ... c4ecb62fd70 -
Thanks for the link.
Problem was solved by decompiling the Microsoft.Navision.Mail.DLL, recompiling it for x86, and re-registering the new DLL on the x64 service tier machine.0 -
hello
Could you explain in detail what you had to do. I'm going to install on 64 bit OS as well and wanted to know how you did this. Thanks.0 -
I've had to deal with this twice and it's been a 'muddle through' each time. Would an enterprising person be willing to put together a How-To on getting SMTP to behave in 64 bit OS?JEREMY VYSKA
CEO, Spare Brained Ideas, Göteborg, Sweden
New (April 2021) Getting Started with Microsoft Dynamics 365 Business Central Book Available: "Your First 20 Hours with Business Central"0 -
If anyone wanders across this, try manually registering the DLL.
Pop open command line as administrator, then head to the Program Files (x86)\Common Files\Microsoft Dynamics NAV\Mail folder. Then it's something like:C:\windows\Microsoft.NET\Framework\v2.0.50727\regasm Microsoft.Navision.Mail.dll /tlb:Microsoft.Navision.Mail.tlb /codebase
That seemed to be all that was necessary this latest time.JEREMY VYSKA
CEO, Spare Brained Ideas, Göteborg, Sweden
New (April 2021) Getting Started with Microsoft Dynamics 365 Business Central Book Available: "Your First 20 Hours with Business Central"0 -
Thanks. That solved my Problems. Big Up.0
-
Also wrote up this PSA on SMTP's DLL and how you install. Ah, installers... they're so fun.JEREMY VYSKA
CEO, Spare Brained Ideas, Göteborg, Sweden
New (April 2021) Getting Started with Microsoft Dynamics 365 Business Central Book Available: "Your First 20 Hours with Business Central"0 -
Hi there,
I'm working with NAV 6 R2 - Hotfixed version (OS: Windows Server 2008 R2 Standard 64bit) and I've tried every solution in this thread with no luck. ](*,)
Things I've tried:
1. Registering Microsoft.Navision.Mail files manually using regasm.exe
2. Re-installing using setup.exe in the root directory of the installation disc
3. I didn't try recompiling the dll but I don't think this would be neccessary as I'm working with a 64bit Operating system.
4. I've also tried registering the Microsoft.Navision.Mail files from previous versions (6 R2 and 6 sp1).
I still get the following error: This message is for C/AL programmers: Unable to create an instance of Automation Server Microsoft.Navision.Mail.SmtpMessage with CLSID = f9dae2a4-d2f8-37c3-86d5-e4ffe166d860 Retrieving the COM class factory for component with CLSID {F9DAE2A4-D2F8-37C3-86D5-E4FFE166D860} failed due to the following error: 80070002..
Does anybody have any ideas that could point me in the right direction?Regards,
Vincent Connell0 -
Hi guys!
I ended up finding the solution! \:D/
I searched around and found this: http://support.microsoft.com/kb/175804
I gave "Everyone" read permission to the following registry keys on the service tier and this solved the problem immediately:
HKEY_CLASSES_ROOT
\LICENCES
\CEDD4F80-B43C-11cf-837C-00AA00573EDE
HKEY_CLASSES_ROOT
\ADODB.Command
\ADODB.Connection
\ADODB.Parameter
\ADODB.Recordset
So my thinking is that this problem could be solved by any one of the solutions mentioned in this thread but when I get this problem in the future I'll start my troubleshooting by checking the permissions in the registry.Regards,
Vincent Connell0
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