Hi, Readers.
Today I would like to talk about Cc and Bcc in Email Editor.
As you might know, you can easily share information and documents, such as sales and purchase orders and invoices, by email directly from Business Central, without having to open an email app.
For exmaple, Choose Email Confirmation… in Sales Order list:
Choose Send by Email in Posted Sales Invoices:
Page: Email Editor (13, Document)
Table: Email Outbox (8888)
PS: To enable emails from within Business Central, start the Set Up Email assisted setup guide. For more information, see Set Up Email.
The To here is automatically filled with the email address associated with the customer or vendor. More details: Change default customer/vendor email address when sending emails (For example, sending an order to A, sending an invoice to B)
When you click Show more, you will see two fields, Cc and Bcc.
Cc (carbon copy)
Specifies the email addresses of people who should receive a copy of the email.
Bcc (blind carbon copy)
Specifies the email addresses of people who should receive a blind carbon copy (Bcc) of the email. These addresses are not shown to other recipients.
This is the same as in Outlook.
And generally, these two values are filled in manually. So the first question is can we set default Cc and Bcc?
Yes, but please note this feature will be deprecated. Let’s see more details.
In BC, there is the following page.
We can force Business Central to run “page 2132 “O365 Invoice Send Settings”” by adding the ?page=2132 parameter to the URL, such as in the following example:
https://businesscentral.dynamics.com/d8f36038-1f93-4543-affc-5dc92b6ee871/Sandbox224?page=2132
Click CC and BCC.
Email for all new invoices page will be opened.
We can choose New to add email addresses in CC and BCC.
And you can add more than one.
Then when sending the the email, Cc and Bcc will be added automatically.
Test video:
The next question is if this feature is removed, can we customize it ourselves? Yes, I looked into the source code and the process is hidden somewhere deep.
You can skip the in-depth process below.
page 9305 “Sales Order List” -> action(“Email Confirmation”) -> DocPrint.EmailSalesHeader(Rec)
codeunit 229 “Document-Print” -> procedure EmailSalesHeader -> local procedure DoPrintSalesHeader
local procedure DoPrintSalesHeader -> ReportSelections.SendEmailToCust
table 77 “Report Selections” -> procedure SendEmailToCustDirectly
local procedure SendEmailToCustDirectly -> local procedure SendEmailDirectly
local procedure SendEmailDirectly -> DocumentMailing.EmailFile
codeunit 260 “Document-Mailing” -> procedure EmailFile -> local procedure EmailFileInternal (There are many EmailFile procedures, all calling EmailFileInternal)
Then you can find the process. TempEmailItem.AddCcBcc():
table 9500 “Email Item” -> procedure AddCcBcc
So we can simply subscribe to the following event.
local procedure OnBeforeSendEmail(var TempEmailItem: Record "Email Item" temporary; var IsFromPostedDoc: Boolean; var PostedDocNo: Code[20]; var HideDialog: Boolean; var ReportUsage: Integer; var EmailSentSuccesfully: Boolean; var IsHandled: Boolean; EmailDocName: Text[250]; SenderUserID: Code[50]; EmailScenario: Enum "Email Scenario")
begin
end;
Let’s look at a simple example.
Very simple😁. In addition, because of the sequence of event execution, the default settings of Cc and Bcc will be overwritten. And as long as the event still exists, we can do the same. Give it a try!!!😁
Source code:
codeunit 50112 CcBccHandle
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Document-Mailing", OnBeforeSendEmail, '', false, false)]
local procedure OnBeforeSendEmail(var TempEmailItem: Record "Email Item" temporary);
begin
TempEmailItem."Send CC" := '111@q.com;333@b.com';
TempEmailItem."Send BCC" := '222@c.com';
end;
}
3. Microsoft Timeline for Deprecating Code in Business Central
END
Hope this will help.
Thanks for reading.
ZHU
コメント