# "Client callbacks are not supported" error

**URL:** <https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463>\
**Category:** Developers Forum\
**Created:** [May 22, 2018, 12:57pm UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463 "2018-05-22T12:57:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![aitorNAV](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@aitorNAV](https://www.dynamicsuser.net/u/aitorNAV)\
**Post date:** [May 22, 2018, 12:57pm UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/1 "2018-05-22T12:57:35Z")

</div>

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:

```auto
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:

```auto
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:  
[![pastedimage1526993845343v1.png](https://us1.discourse-cdn.com/flex023/uploads/dugusers/original/2X/1/1f31e7965ef681e638b5f8e17747ca1596b85b28.png)](https://us.v-cdn.net/5022383/uploads/editor/dm/ex5wl2vw5jmc.png)  
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

---

<div class="post-metadata">

**Author:** ![pjllaneras](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/pjllaneras/32/9768_2.png) [@pjllaneras](https://www.dynamicsuser.net/u/pjllaneras)\
**Post date:** [May 22, 2018, 2:21pm UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/2 "2018-05-22T14:21:34Z")

</div>

Hi Aitor,

Why are you using FileManagement.DownloadToFile() function? If I understand correctly, you are launching this process trought web service, in that case there are no client at all, you don’t need to download file, your “client” is your server.

Try to remove “ClientDestination” part and test it again.

---

<div class="post-metadata">

**Author:** ![aitorNAV](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@aitorNAV](https://www.dynamicsuser.net/u/aitorNAV)\
**Post date:** [May 22, 2018, 2:44pm UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/3 "2018-05-22T14:44:00Z")

</div>

Hola Ponç,

Thank you for your answer. I’ve changed mycode:

```auto
//<<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:

```auto
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

```

I’ve read in another post that this could be because I am using CodeUnit397, which uses Outllok Integration, and this could make the error. Do you think that this could be becasue of that, and using CU 400 will be better?

Thnak you very much

---

<div class="post-metadata">

**Author:** ![admin1](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/admin1/32/7476_2.png) [@admin1](https://www.dynamicsuser.net/u/admin1)\
**Post date:** [May 22, 2018, 4:39pm UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/4 "2018-05-22T16:39:06Z")

</div>

Yes, you need to be using codeunit 400 SMTP Mail, if you want to call it without having Outlook installed. Codeunit 397 depends on a user interface and Outlook. SMTP mail needs an SMTP mail server.

---

<div class="post-metadata">

**Author:** ![aitorNAV](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@aitorNAV](https://www.dynamicsuser.net/u/aitorNAV)\
**Post date:** [May 23, 2018, 7:23am UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/5 "2018-05-23T07:23:20Z")

</div>

Thank you Erik, as always.  
And if I use Job Queues instead of task Scheduler, will it work with CU397? Or I will have the same problem? It’s important to know that, in the server, outlook is installed…

---

<div class="post-metadata">

**Author:** ![pjllaneras](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/pjllaneras/32/9768_2.png) [@pjllaneras](https://www.dynamicsuser.net/u/pjllaneras)\
**Post date:** [May 23, 2018, 7:27am UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/6 "2018-05-23T07:27:09Z")

</div>

Hola Aitor,

Job Queue will have same beaviour than task schyeduler, will run on server, you can’t run anything there that will require user interaction and CU397 will.

---

<div class="post-metadata">

**Author:** ![aitorNAV](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@aitorNAV](https://www.dynamicsuser.net/u/aitorNAV)\
**Post date:** [May 23, 2018, 7:33am UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/7 "2018-05-23T07:33:45Z")

</div>

Hola,

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

---

<div class="post-metadata">

**Author:** ![admin1](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/admin1/32/7476_2.png) [@admin1](https://www.dynamicsuser.net/u/admin1)\
**Post date:** [May 23, 2018, 10:49am UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/8 "2018-05-23T10:49:30Z")

</div>

It’s actually easier to have different senders depending on the customer with SMTP (400), than with Mapi (397). MAPI will always use the account configured with Outlook, whereas SMTP allow you to specify it per mail.

---

<div class="post-metadata">

**Author:** ![aitorNAV](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@aitorNAV](https://www.dynamicsuser.net/u/aitorNAV)\
**Post date:** [May 23, 2018, 10:55am UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/9 "2018-05-23T10:55:53Z")

</div>

In Mapi, I configure the direction with this statement:

```auto
FromMail := 'info@xxxxxx.com';

```

Can I do something like this with SMTP? I thought that the only sender account was the one that was configured in the SMTP server-…

---

<div class="post-metadata">

**Author:** ![admin1](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/admin1/32/7476_2.png) [@admin1](https://www.dynamicsuser.net/u/admin1)\
**Post date:** [May 23, 2018, 10:58am UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/10 "2018-05-23T10:58:12Z")

</div>

Yes. If you do so in Mapi, then it doesn’t really give you anything. Check the received mail, it will be send from the MAPI user.

Only exception is that you can configure some account to be used by more users.

---

<div class="post-metadata">

**Author:** ![aitorNAV](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@aitorNAV](https://www.dynamicsuser.net/u/aitorNAV)\
**Post date:** [May 23, 2018, 11:02am UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/11 "2018-05-23T11:02:35Z")

</div>

Thank you Ernst, I’ll work on it!

I’ve got a few more task to do, but when I try this, I’ll give the feedback!!

Really thanks!

---

<div class="post-metadata">

**Author:** ![aitorNAV](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@aitorNAV](https://www.dynamicsuser.net/u/aitorNAV)\
**Post date:** [May 25, 2018, 11:36am UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/12 "2018-05-25T11:36:36Z")

</div>

Hello [mention:61b2aa9ce72e429baa1ef43208ddbea4:e9ed411860ed4f2ba0265705b8793d05]

Until I receive the SMTP configuration data from our customer, I’m making test configuring with my own gmail account. I’m receiveing the mail correctly, but I’'m receiving from my gmail account, instead of the company mail. I’m creating the message this way:

```auto
mailSMTP.CreateMessage('info@xxxxxxx.com','info@xxxxxxx.com','yyyyyyy@yyyyyy.coop','envio prueba',textoCuerpo, FALSE);
mailSMTP.AddAttachment(ServerDestination+Tofile,Tofile);

```

What should I change for configure the email that I want to send from?

Thank you very much!!

---

<div class="post-metadata">

**Author:** ![admin1](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/admin1/32/7476_2.png) [@admin1](https://www.dynamicsuser.net/u/admin1)\
**Post date:** [May 25, 2018, 2:46pm UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/13 "2018-05-25T14:46:11Z")

</div>

The syntax for the function is:

**CreateMessage(SenderName: Text;SenderAddress: Text;Recipients: Text;Subject: Text;Body: Text;HtmlFormatted: Boolean)**

So you need to change the sender address, the first is just the display name. But it also depends on the SMTP server you are using. If you use GMails SMTP, then you are actually using your own account. I’m using Office365’s SMTP servers to send mails from my NAV, and here the email I’m using just need to been from one of the domains I have registered on my subscription.

---

<div class="post-metadata">

**Author:** ![aitorNAV](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@aitorNAV](https://www.dynamicsuser.net/u/aitorNAV)\
**Post date:** [May 28, 2018, 9:36am UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/14 "2018-05-28T09:36:21Z")

</div>

So, as I supposed, I was using correctly the CreateMessage function, but the issue is other… Isn’t possible to send emails from different accounts if we have configured a gmail account on SMTP?

Our customer, needs teh mails to be sent from different account, depending on if they are from Spain, or not.

AS far as I understood, you have configures your O365 account, and yo can’t send mails from he account of that susbscription, am I right? If the custoemr hasn’t got a O365 subscription, can we send emails from different account in another way? Or it’s just imposible? If it’s possible, which are the requisites?

Thank you very much!

---

<div class="post-metadata">

**Author:** ![PalleA](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@PalleA](https://www.dynamicsuser.net/u/PalleA)\
**Post date:** [May 28, 2018, 9:48am UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/15 "2018-05-28T09:48:53Z")

</div>

Codeunit 400 only rely on the SMT-mail Setup table. So if you want to send emails from different UserIDs then you either have to

1. Change Codeunit 400 where you have inserted the correct Userid/password/smtp-server in a temporary record

2. Add the fields from the SMTP-Mail setup table to eg. a user-table and change codeunit 400 to use that.

---

<div class="post-metadata">

**Author:** ![aitorNAV](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@aitorNAV](https://www.dynamicsuser.net/u/aitorNAV)\
**Post date:** [May 28, 2018, 10:39am UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/16 "2018-05-28T10:39:16Z")

</div>

Interesting… As far as i underastand on what are you saying, I suppose i should change the “TrySend” method, am I right? In that method is where I get the SMTP configuration. But as I see, the “from direction” is setup in the “CreateMessage” function…

---

<div class="post-metadata">

**Author:** ![aitorNAV](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@aitorNAV](https://www.dynamicsuser.net/u/aitorNAV)\
**Post date:** [May 29, 2018, 4:17pm UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/17 "2018-05-29T16:17:54Z")

</div>

Hi again,

I’ve been trying to do differentes test, and debugging, but I think I’m quite lost in this issue.

My code is like this:

```auto
mailSMTP.CreateMessage('info@xxxxx.com','info@xxxxx.com','xxx@yyy.coop','envio prueba',textoCuerpo, TRUE);
mailSMTP.AddAttachment(ServerDestination+Tofile,Tofile);
MailSent := mailSMTP.TrySend;

```

When I call to “CreateMessage”, it goes to CU400, and I can see of the “Mail” DOTNET variable, has the correct direction, the one I’me passing through parameters.

But when I came back to my CU, “mailSMTP” variable has the parameters that have been configured in the SMTP configuration. I’m trying to find the point that validates the SMTP setup, and I’m changing some values, but when I change those values, i get an authentication error…

How can I “skip” the validation or, change those values?

Any hint will be appreciated, thank you very much

---

<div class="post-metadata">

**Author:** ![admin1](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/admin1/32/7476_2.png) [@admin1](https://www.dynamicsuser.net/u/admin1)\
**Post date:** [May 29, 2018, 5:07pm UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/18 "2018-05-29T17:07:19Z")

</div>

> [@](#):
>
> AS far as I understood, you have configures your O365 account, and yo can’t send mails from he account of that susbscription, am I right? If the custoemr hasn’t got a O365 subscription, can we send emails from different account in another way? Or it’s just imposible? If it’s possible, which are the requisites?

That was NOT quite what I wrote! I wrote that if you send mails using GMails’ SMTP server, then you need to make sure that you’re allowed to use the sender email address. O365 works fine, but I need to link the domain I’m sending from (i.e. if I’m sending from [dynamicsuser.net](http://dynamicsuser.net) - then this domain needs to be registered in O365 first. I cannot send a mail with an email from a domain not associated with 0365. I’m not familiar with how GMail works, but assume its something similar.

If you use [xxxxx.com](http://xxxxx.com) as your sender domain, then that domain either has to be @gmail.com or in another way associated with the same account you used to authenticate your SMTP setup. What happens when you use the Test function in SMTP setup? Before dealing with your custom code, then you should make sure SMTP Setup has been tested.

---

<div class="post-metadata">

**Author:** ![aitorNAV](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@aitorNAV](https://www.dynamicsuser.net/u/aitorNAV)\
**Post date:** [May 30, 2018, 9:56am UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/19 "2018-05-30T09:56:22Z")

</div>

Hi [mention:61b2aa9ce72e429baa1ef43208ddbea4:e9ed411860ed4f2ba0265705b8793d05]

Thanks for your answer. FIrst of all, I must say that that our idea is not using gmail in the customer. I’m using gmail for the test, with the hope that it will help me, but it seems to be more problematic.

Our customer has a mail account for the customwers from spain with the domain “[xxxxx.com](http://xxxxx.com)”, and another domain for the customer from the rest of europe, “[yyyyy.com](http://yyyyy.com)”

Is it possible to send emails from different domains? How should setup the SMTP? With which domain?

Sorry about my question, I am auto-didact with all this, and I am really lost about his…

Thank you all again for everything

---

<div class="post-metadata">

**Author:** ![PalleA](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@PalleA](https://www.dynamicsuser.net/u/PalleA)\
**Post date:** [May 30, 2018, 10:05am UTC](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463/20 "2018-05-30T10:05:59Z")

</div>

The answer is still YES, it is possible to send emails with different SMTP Accounts, but still not without programming.

This can be done with less than one hour of programming.

1. Make a copy of the SMTP Table and change the field PRIMARY KEY to eg. COUNTRY

2. Create a page to the new SMTP-Table

3. Add the page to a Role Center

4. Add records with countryspecific SMTP mail settings

5. Add the new SMTP Table primary key field to eg. Customer Posting Group (If that groups yours customers

6. Change the mail send codeunit where it tests from where the customer comes from simply by doing a Transferfields in code.

But before you do ANYTHING make sure that it works with at least one SMTP-mail setup

[Next page](https://www.dynamicsuser.net/t/client-callbacks-are-not-supported-error/65463.md?page=2)
