Codeunit 8907 Email Viewer in 25

App
System Application
Namespace
System.Email

Procedures, 7

Versions171819202122232425262728latest

Source242526272829

Source in 25

src/System Application/App/Email/src/Email/Sent/EmailViewer.Codeunit.al100 lines, Copyright (c) Microsoft Corporation. MIT

// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------

namespace System.Email;

codeunit 8907 "Email Viewer"
{
    Access = Internal;
    InherentPermissions = X;
    InherentEntitlements = X;
    Permissions = tabledata "Sent Email" = ri,
                  tabledata "Email View Policy" = r;

    procedure Open(SentEmail: Record "Sent Email")
    var
        EmailViewer: Page "Email Viewer";
    begin
        CheckPermissions(SentEmail);
        EmailViewer.SetRecord(SentEmail);
        EmailViewer.Run();
    end;

    procedure Resend(SentEmail: Record "Sent Email")
    var
        Email: Codeunit Email;
        NewEmailMessageImpl, OldEmailMessageImpl : Codeunit "Email Message Impl.";
        NewEmailMessage: Codeunit "Email Message";
    begin
        CheckPermissions(SentEmail);

        if not OldEmailMessageImpl.Get(SentEmail."Message Id") then
            Error(EmailMessageDoesNotExistMsg);

        NewEmailMessageImpl.Create(OldEmailMessageImpl);
        NewEmailMessage.Get(NewEmailMessageImpl.GetId());

        Email.Enqueue(NewEmailMessage, SentEmail."Account Id", SentEmail.Connector);

        Message(EmailWasQueuedForSendingMsg);
    end;

    procedure CheckPermissions(SentEmail: Record "Sent Email")
    var
        EmailImpl: Codeunit "Email Impl";
        EmailViewPolicy: Interface "Email View Policy";
    begin
        EmailViewPolicy := EmailImpl.GetUserEmailViewPolicy();
        if EmailViewPolicy.HasAccess(SentEmail) then
            exit;

        Error(EmailMessageOpenPermissionErr);
    end;

    procedure EditAndSend(SentEmail: Record "Sent Email")
    var
        Email: Codeunit Email;
        NewEmailMessageImpl, OldEmailMessageImpl : Codeunit "Email Message Impl.";
        NewEmailMessage: Codeunit "Email Message";
    begin
        CheckPermissions(SentEmail);

        if not OldEmailMessageImpl.Get(SentEmail."Message Id") then
            Error(EmailMessageDoesNotExistMsg);

        NewEmailMessageImpl.Create(OldEmailMessageImpl);
        NewEmailMessage.Get(NewEmailMessageImpl.GetId());

        Email.OpenInEditor(NewEmailMessage, SentEmail."Account Id", SentEmail.Connector);
    end;

    procedure GetEmailAccount(SentEmail: Record "Sent Email"; var EmailAccount: Record "Email Account");
    var
        EmailAccounts: Codeunit "Email Account";
    begin
        EmailAccounts.GetAllAccounts(EmailAccount);

        if not EmailAccount.Get(SentEmail."Account Id", SentEmail.Connector) then
            Clear(EmailAccount);
    end;

    procedure GetEmailMessage(var SentEmail: Record "Sent Email"; var EmailMessageImpl: Codeunit "Email Message Impl.");
    begin
        if not EmailMessageImpl.Get(SentEmail."Message Id") then
            Error(EmailMessageDoesNotExistMsg);
    end;

    procedure RefreshSentMailForUser(AccountId: Guid; NewerThan: DateTime; SourceTableID: Integer; SourceSystemID: Guid; var SentEmailForUser: Record "Sent Email" temporary)
    var
        EmailImpl: Codeunit "Email Impl";
    begin
        EmailImpl.GetSentEmails(AccountId, NewerThan, SourceTableID, SourceSystemID, SentEmailForUser);
    end;

    var
        EmailMessageOpenPermissionErr: Label 'You do not have permission to open the email message.';
        EmailMessageDoesNotExistMsg: Label 'The email message has been deleted by another user.';
        EmailWasQueuedForSendingMsg: Label 'The message was queued for sending.';
}

Procedures, 7

NameParametersReturnsAccessObsolete
Open(Record Sent Email)public-
Resend(Record Sent Email)public-
CheckPermissions(Record Sent Email)public-
EditAndSend(Record Sent Email)public-
GetEmailAccount(Record Sent Email, var Record Email Account)public-
GetEmailMessage(var Record Sent Email, var Codeunit Email Message Impl.)public-
RefreshSentMailForUser(Guid, DateTime, Integer, Guid, var Record Sent Email)public-