ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Access Request] Table 8888 "Message Id"

Open danielzuppiger opened this issue 5 years ago • 8 comments

Hi,

We'd like to add attachments to an E-Mail before sending it (Email Editor, P13 T8888) - not by the default functionality, but by a custom one. As far as I can see, we would need access to the Message Id for that to be possible. Can you make it accessible somehow or provide us a solution, on how we could implement such a feature?

Thanks in advance.

danielzuppiger avatar Nov 16 '21 08:11 danielzuppiger

Hi @danielzuppiger!

Codeunit 9520 "Mail Management" currently expose some events when sending through the module, passing on the "Email Message" codeunit. Through the codeunit you should be able to add the attachments.

Do the below events work for your scenario? If not, please explain in more detail the scenario you want supported.

Events:

    [IntegrationEvent(false, false)]
    local procedure OnSendViaEmailModuleOnAfterAddAttachments(var Message: Codeunit "Email Message"; var TempEmailItem: Record "Email Item" temporary)
    begin
    end;

    [IntegrationEvent(false, false)]
    local procedure OnSendViaEmailModuleOnAfterCreateMessage(var Message: Codeunit "Email Message"; var TempEmailItem: Record "Email Item" temporary)
    begin
    end;

    [IntegrationEvent(false, false)]
    local procedure OnSendViaEmailModuleOnAfterEmailSend(var Message: Codeunit "Email Message"; var TempEmailItem: Record "Email Item" temporary; var MailSent: Boolean; var Cancelled: Boolean; var HideEmailSendingError: Boolean)
    begin
    end;

stkillen avatar Nov 26 '21 11:11 stkillen

Hi @stkillen,

thank you very much for your reply!

We would like to add attachments through a page action. In previous versions of BC/NAV, we implemented a feature that lets you select various related documents (e.g. if you want to send an order confirmation and the mail preview pops up, you can add the blanket order, picking list, and so on) and automatically add their generated PDF file as an attachment to the e-mail.

Therefore, these events are not working for our scenario. Do you have any idea how to implement this for the new email feature? Otherwise, we would resort to running the feature when the preview is opened.

danielzuppiger avatar Nov 29 '21 07:11 danielzuppiger

I see, thanks! It should be possible to do that.

Page 13 "Email Editor" is extensible, so you can add your action to the page. You can get the message id from the source record (source table is "Email Outbox"): Rec."Message Id". From there on, you should be able to add attachments you want to the email message.

Let me know if that solves your issue or if there's any problems.

stkillen avatar Nov 29 '21 11:11 stkillen

Thanks for your reply.

But that was my point in the original post. The field "Message Id" is set to Internal. image

Therefore, I cannot access it trough code: image

The description of the field says, that it is internal in order to prevent modifying it from code. Could you implement a getter function or would this cause complication?

danielzuppiger avatar Nov 29 '21 14:11 danielzuppiger

I guess there should then be also added a getter on the attachment sub page. https://github.com/microsoft/ALAppExtensions/blob/f1cace7c948c2006d79052106481c6ebcade8944/Modules/System/Email/src/Message/EmailAttachments.Page.al#L137

duichwer avatar Dec 02 '21 21:12 duichwer

Thanks for you input!

We've discussed how to best support this and decided on introducing a getter for the Email Message codeunit on the page.

Signature: procedure GetEmailMessage() EmailMessage: Codeunit "Email Message"

stkillen avatar Dec 08 '21 10:12 stkillen

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.

JesperSchulz avatar Dec 16 '21 08:12 JesperSchulz

Availability update: We will publish a fix for this issue in the next update for release 19.

JesperSchulz avatar Jan 04 '22 09:01 JesperSchulz