Thanks four your answer [mention:74275055534c437ab13054c27a1ed5fb:e9ed411860ed4f2ba0265705b8793d05], it is really interesting.
What I understand from the first 3 steps, is that I should create a copy of the SMTP table (409), for creating a new configuration, for the second domain. Shouldn’t be enough to create a new line when I run this table for the new configuration?
The reason I see to create a new table is this one:
I can create a new one, for adding there the 2 domains, and with a different key, so in this way, I will use the new table, and forget about the “default” one. Am I right? In this way, I could obatin the SMTP, depending on a key I have created that is suitable for my development, as the country, or sending group for example…
No you cannot do that. Notice the first field ind the SMTP Table. It says Primary Key = this means that according to standard NAV AL/Code there can only be 1 Record and that field is blank!!!
If you create more than one record in the table then SMTPSetup.GET; which is written in many codeunits you cannot do a get with a GET(RECORDID) = FAIL on all your mails.
Do as suggested create a NEW SMTP-table with more records and when you have to send an email do am SMTPSetup.Transferfrelds(NEWsmtpSetup);
Well you could change the primarykey from code to DATE - and then compile all objects to find where SMTP.GET is used - Then you’ll know how much you have to change - then you dont need a new table.
Thanks Palle. So I was right, the idea of creationg a new table, is to add there the recorsds for both domains, and when sending an email, use that table instead of the default one.
I think I will use this approach, because in this way, the default objets won’t be changed, I’ll use the nre ones.
That’s how I can configure my O365 account. As long I own both the xxxxx.com and yyyyy.com domains, then I can associated them with my account and use either xxxxx.com or yyyyy.com email addresses as the sender when using the same O365 subscription. Technically I have associated my servers IP address with the subscription, allowing me to connect to the O365 SMTP service for my subscription.
But that’s 0365, what is possible depends on which email service your customer is using.
So start by making sure SMTP mail works! Especially with the customer. You need to make sure that they have access to an SMTP server for their domains. You should talk to their IT department if they have one. Most do, but many have no idea about this option. All this work is wasted, if SMTP is not an option. This really has NOTHING to do with NAV at this state. This is a technical/infrastructure issue but that is your first priority.
Forget about enabling multiple SMTP Setups per NAV. It will require you to change the functionality almost everywhere, where the SMTP Setup is used in standard NAV. Especially with your limited knowledge about NAV. And why would you even need it, if you can do it without?
Thnak you Erik. Our customers hasn’t got O365, so this is discarded. I started doieng the test with gamil, because i still haven’t got the SMTP configuration of our customer, and now it is in a fair, so I must wait a few weeks more.
Do you really think that I should change too much things, weith the approach that [mention:74275055534c437ab13054c27a1ed5fb:e9ed411860ed4f2ba0265705b8793d05] as proposed? I don’t think that iot would give me too much problem…
Even GMail allows you to associate different domains, if you use their professional offerings. Most professional email services, includes this kind of configurations If they run their own SMTP server, then certainly it will be possible.
So yes I think you should not worry to much about it, but assume that it’s a matter of configuration.
Change SMTP Setup will give you more things to worry about, and you need less. [emoticon:c4563cd7d5574777a71c318021cbbcc8]
This is really interesting, thanks Erik. So i understand that, in a gmail account, I can associate both customer`s emails, and in SMTP setup, just configure the gmail account?
Sounds really good to, and as I’ve said before, I must wait a few weeks for the SMTP configuration, I think I will alsoread about associating the email account to one gmail account.
YOU cannot associated your customers emails/domains with your account! But if they are using GMail has their company email service, then THEY can configure it to sent from the domains they have associated with their account.
First of all, thank you to everyone you hav ehelped me with your hints. I’ve solved the issue with an auxiliar table for the SMTP, and creating this method:
[External] TrySendOPT(customer : Record Customer) : Boolean
OnBeforeTrySend;
SendResult := '';
IF customer."Customer Type" < 3 THEN BEGIN
SMTPoptional.GET('1');
SMTPMailSetup.TRANSFERFIELDS(SMTPoptional);
END ELSE BEGIN
SMTPoptional.GET('2');
SMTPMailSetup.TRANSFERFIELDS(SMTPoptional);
END;
Password := SMTPMailSetup.GetPassword;
WITH SMTPMailSetup DO
SendResult :=
Mail.Send(
"SMTP Server",
"SMTP Server Port",
Authentication <> Authentication::Anonymous,
"User ID",
Password,
"Secure Connection");
Mail.Dispose;
CLEAR(Mail);
EXIT(SendResult = '');
One last question… What should I do to see the sent email in the mailbox?
Good work (even though I DONT LIKE that you have hardcoded the GET(‘X’) part…
The big difference between the ordinary mail codeunit and the SMTP codeunit is two things. The normal mail requires Outlook to be installed AND you can see the sent mail in your sent folder.
SMTP does not require outlook to be installed - AND it does NOT save af copy of your mails in the sent folder. If you search a little here on Dynamics User Group you’ll see that I have suggested in order to keep af copy of a sent mail that you mail yourself as BCC