"Client callbacks are not supported" error
AitorEG
Member Posts: 342
Hi everyone,
First of all, I'm gonna explain my intentios of doing this development, may be I am a bit confused, and I can do it in another way that doesn't launch this error.
My idea is to periodically send an email with an attached PDF to different customers. This is an approach to the developmet.
First of all, I run this method in a CodeUnit:
And this method, calls to this one:
As you can see, I find some customer, and I send a report to each of them. First of all, I create the PDF file in a folder, and afterm I attach it to the email.
This works perfectly when I run the codeUnit, but as I want to send the mails periodically, I must to use the "Task Scheduler". For this, I have created an script that calls to the method in the CodeUnit, but when I run the script, I can see this error:

I've read in different places, that could be somethin with the "GUIALLOWED" property, but I don't see how should I fix this issue.
Any hint?
Thank you vey much
First of all, I'm gonna explain my intentios of doing this development, may be I am a bit confused, and I can do it in another way that doesn't launch this error.
My idea is to periodically send an email with an attached PDF to different customers. This is an approach to the developmet.
First of all, I run this method in a CodeUnit:
OutstandingOrderLines()
lCustomer.RESET;
lCustomer.SETRANGE("Send Outstanding Orders", TRUE);
IF lCustomer.FINDSET THEN
REPEAT
SendOutstanding2Customer(lCustomer, 50074);
UNTIL lCustomer.NEXT=0;
And this method, calls to this one:
SendOutstanding2Customer(VAR pCustomer : Record Customer;ReportID : Integer)
IF NOT ISSERVICETIER THEN
EXIT;
CLEAR(ToMail);
CLEAR(FromMail);
CLEAR(EmailHeader);
CLEAR(EmailBody);
CLEAR(EmailFoot);
CLEAR(Mail);
CLEAR(ServerDestination);
CLEAR(ClientDestination);
CLEAR(Customer);
PurchSetup.GET;
EmailHeader := PurchSetup."eMail Header for Sales Info";
EmailFoot := PurchSetup."eMail Foot for Sales Info";
EmailBody := '';
ToMail := pCustomer."E-Mail";
FromMail := 'info@xxxxxx.com';
ServerDestination := 'C:\Users\Public\Documents\';
Tofile := STRSUBSTNO('Outstanding orders %1,%2.pdf', FORMAT(TODAY,0,'<Year,2><Day,2><Month,2>'), pCustomer.Name);
REPORT.SAVEASPDF(ReportID,ServerDestination + Tofile,pCustomer);
//REPORT.SAVEASEXCEL(ReportID,ServerDestination + Tofile);
ClientDestination := 'C:\Users\Public\Documents\';
FileManagement.DownloadToFile(ServerDestination + Tofile,ClientDestination + Tofile);
Mail.CreateNewMessage2(FromMail,ToMail,'',Tofile,EmailHeader,EmailBody,EmailFoot,ClientDestination + Tofile,FALSE);
As you can see, I find some customer, and I send a report to each of them. First of all, I create the PDF file in a folder, and afterm I attach it to the email.
This works perfectly when I run the codeUnit, but as I want to send the mails periodically, I must to use the "Task Scheduler". For this, I have created an script that calls to the method in the CodeUnit, but when I run the script, I can see this error:

I've read in different places, that could be somethin with the "GUIALLOWED" property, but I don't see how should I fix this issue.
Any hint?
Thank you vey much
0
Answers
-
I guess Mail variable is referencing Codeunit 397.
Codeunit 397 uses oultlok integration, which runs in user sessions, uses user mail profile, etc. When you run it from Task Scheduler there is no user session.
Try to used Codeunit 400 SMTP mail instead.Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-031 -
Thanks for your answer @Slawek_Guzek. I'll work on it, but in the error, it looks that the first failure is with the file maangement. In fact, the PDF is not generated in the folder....
edit: I've commented the part of sending the e-mail, just for creating the PDF file, and the rror persists, so it looks that the first error is that one.0 -
Hi @Slawek_Guzek,
I've changed the code://<<180503-01>> IF NOT ISSERVICETIER THEN EXIT; // IF GUIALLOWED THEN // EXIT; CLEAR(ToMail); CLEAR(FromMail); CLEAR(EmailHeader); CLEAR(EmailBody); CLEAR(EmailFoot); CLEAR(Mail); CLEAR(ServerDestination); CLEAR(ClientDestination); CLEAR(Customer); PurchSetup.GET; EmailHeader := PurchSetup."eMail Header for Sales Info"; EmailFoot := PurchSetup."eMail Foot for Sales Info"; EmailBody := ''; ToMail := pCustomer."E-Mail"; FromMail := 'info@basemetalurgica.com'; ServerDestination := 'C:\Users\Public\Documents\'; Tofile := STRSUBSTNO('Outstanding orders %1,%2.pdf', FORMAT(TODAY,0,'<Year,2><Day,2><Month,2>'), pCustomer.Name); REPORT.SAVEASPDF(ReportID,ServerDestination + Tofile,pCustomer); Mail.CreateNewMessage2(FromMail,ToMail,'',Tofile,EmailHeader,EmailBody,EmailFoot,ServerDestination + Tofile,FALSE);
And now, the error is:System.Web.Services.Protocols.SoapException: Microsoft Dynamics NAV Business Web Services attempted to issue a client callback to create a DotNet object: Microsoft.Office.Interop.Outlook.ApplicationClass (CodeUnit 397 Mail). Client callbacks are not supported on Microsoft Dynamics NAV Business Web Services. en System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) en System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) en SendOutsOrders.WebService.BasemetaFunc.OutstandingOrderLines() en c:\Users\Administrador\Documents\Visual Studio 2012\Projects\SendOutsOrders\SendOutsOrders\Web References\WebService\Reference.cs:l¡nea 341 en SendOutsOrders.Program.Main(String[] args) en c:\Users\Administrador\Documents\Visual Studio 2012\Projects\SendOutsOrders\SendOutsOrders\Program.cs:l¡nea 26
This could be becasue of what you'ce said, about he codeUnit 397?
Thank you very much0 -
Using the CU400, means that I should configure the SMTP server, am i right??0
-
Yes, you need to setup the SMPT server address/port/authentication.
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Slawek_Guzek wrote: »Yes, you need to setup the SMPT server address/port/authentication.
Thank you Slawek. And if I use Job Queues instead of task Scheduler, will it work with CU397? Or I will have the same problem?0 -
Yes, it's gonna to be the same problem. Stick to the C400 SMPT Mail.Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Slawek_Guzek wrote: »Yes, it's gonna to be the same problem. Stick to the C400 SMPT Mail.
Thanks Slawek.
So, I think that could be a problem, because I will probably want to send e-mails from different mail accounts, depending on the customer. That will be quite easy with CU397, but if I use CU400, I should configure the SMTP server, and that is for the whole company.... Am I right?
Thank you very much0 -
Slawek_Guzek wrote: »Yes, it's gonna to be the same problem. Stick to the C400 SMPT Mail.
Thanks Slawek.
So, I think that could be a problem, because I will probably want to send e-mails from different mail accounts, depending on the customer. That will be quite easy with CU397, but if I use CU400, I should configure the SMTP server, and that is for the whole company.... Am I right?
Thank you very much
the from mail could be anyone authorised by the mail support by the mail you've config.
I've done it, I've only one config account by I've send by other depends if the department is sales, or purchase, manufacturing, etc.0
Categories
- All Categories
- 73 General
- 73 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 333 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
