Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/484133 drag and drop attach multiple files (email attachment part) #842

Merged
merged 15 commits into from
Apr 10, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,24 @@ codeunit 8906 "Email Editor"
var
FileName: Text;
Instream: InStream;
AttachmentName, ContentType : Text[250];
AttachamentSize: Integer;
begin
UploadIntoStream('', '', '', FileName, Instream);
if FileName = '' then
exit;

UploadAttachment(EmailMessageImpl, FileName, Instream);
end;

procedure UploadAttachment(EmailMessageImpl: Codeunit "Email Message Impl."; FileName: Text; Instream: InStream)
var
AttachmentName, ContentType : Text[250];
AttachmentSize: Integer;
begin
AttachmentName := CopyStr(FileName, 1, 250);
ContentType := EmailMessageImpl.GetContentTypeFromFilename(FileName);
AttachamentSize := EmailMessageImpl.AddAttachmentInternal(AttachmentName, ContentType, Instream);
AttachmentSize := EmailMessageImpl.AddAttachmentInternal(AttachmentName, ContentType, Instream);

Session.LogMessage('0000CTX', StrSubstNo(UploadingAttachmentMsg, AttachamentSize, ContentType), Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', EmailCategoryLbl);
Session.LogMessage('0000CTX', StrSubstNo(UploadingAttachmentMsg, AttachmentSize, ContentType), Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', EmailCategoryLbl);
end;

procedure DownloadAttachment(MediaID: Guid; FileName: Text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ page 8889 "Email Attachments"
{
repeater(GroupName)
{
FileUploadAction = UploadMultiple;
field(FileName; Rec."Attachment Name")
{
ApplicationArea = All;
Expand Down Expand Up @@ -53,15 +54,41 @@ page 8889 "Email Attachments"
{
area(Processing)
{
fileuploadaction(UploadMultiple)
{
ApplicationArea = All;
Image = Attach;
Caption = 'Add files';
ToolTip = 'Attach files, such as documents or images, to the email.';
Scope = Page;
Visible = IsEmailEditable;

trigger OnAction(files: List of [FileUpload])
var
EmailEditor: Codeunit "Email Editor";
TempInStream: InStream;
SingleFile: FileUpload;
begin
foreach SingleFile in files do begin
SingleFile.CreateInStream(TempInStream, TextEncoding::UTF8);
if SingleFile.FileName <> '' then
EmailEditor.UploadAttachment(EmailMessageImpl, SingleFile.FileName, TempInStream);
end;
UpdateDeleteActionEnablement();
end;
}
#if not CLEAN25
action(Upload)
{
ObsoleteState = Pending;
ObsoleteReason = 'The action Upload is replaced by the new action UploadMultiple.';
ObsoleteTag = '25.0';
ApplicationArea = All;
Image = Attach;
Caption = 'Add file';
ToolTip = 'Attach files, such as documents or images, to the email.';
Scope = Page;
Visible = IsEmailEditable;
Visible = false;

trigger OnAction()
var
Expand All @@ -71,7 +98,7 @@ page 8889 "Email Attachments"
UpdateDeleteActionEnablement();
end;
}

#endif
action(UploadFromScenario)
{
ApplicationArea = All;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,11 @@ codeunit 134692 "Email E2E Tests"
Assert.AreEqual(Body, EmailViewer.BodyField.Value(), 'Body field value is incorrect');

Assert.IsFalse(EmailViewer.Attachments.Delete.Visible(), 'Delete attachment is visible');
#if not CLEAN25
#pragma warning disable AL0432
Assert.IsFalse(EmailViewer.Attachments.Upload.Visible(), 'Visible attachment is visible');

#pragma warning restore
#endif
Assert.IsTrue(EmailViewer.Resend.Visible(), 'Resend action should be visible');
Assert.IsTrue(EmailViewer.Resend.Enabled(), 'Resend action should be enabled');

Expand Down
14 changes: 13 additions & 1 deletion src/System Application/Test/Email/src/EmailTest.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,11 @@ codeunit 134685 "Email Test"
Assert.IsFalse(EmailEditor.BccField.Editable(), 'Bcc field was editable');
Assert.IsFalse(EmailEditor.SubjectField.Editable(), 'Subject field was editable');
Assert.IsFalse(EmailEditor.BodyField.Editable(), 'Body field was editable');
#if not CLEAN25
#pragma warning disable AL0432
Assert.IsFalse(EmailEditor.Attachments.Upload.Visible(), 'Upload Action is visible.');
#pragma warning restore
#endif
Assert.IsFalse(EmailEditor.Send.Enabled(), 'Send Action was not disabled.');

EmailOutBox.Status := Enum::"Email Status"::Processing;
Expand All @@ -317,7 +321,11 @@ codeunit 134685 "Email Test"
Assert.IsFalse(EmailEditor.BccField.Editable(), 'Bcc field was editable');
Assert.IsFalse(EmailEditor.SubjectField.Editable(), 'Subject field was editable');
Assert.IsFalse(EmailEditor.BodyField.Editable(), 'Body field was editable');
#if not CLEAN25
#pragma warning disable AL0432
Assert.IsFalse(EmailEditor.Attachments.Upload.Visible(), 'Upload Action is visible.');
#pragma warning restore
#endif
Assert.IsFalse(EmailEditor.Send.Enabled(), 'Send Action was not disabled.');
EmailMessageAttachment.SetRange("Email Message Id", EmailMessage.GetId());
EmailMessageAttachment.FindFirst();
Expand Down Expand Up @@ -1454,7 +1462,11 @@ codeunit 134685 "Email Test"
Assert.IsTrue(EmailEditor.BccField.Editable(), 'Bcc field was not editable');
Assert.IsTrue(EmailEditor.SubjectField.Editable(), 'Subject field was not editable');
Assert.IsTrue(EmailEditor.BodyField.Editable(), 'Body field was not editable');
Assert.IsTrue(EmailEditor.Attachments.Upload.Visible(), 'Upload Action is not visible.');
#if not CLEAN25
#pragma warning disable AL0432
Assert.IsFalse(EmailEditor.Attachments.Upload.Visible(), 'Upload Action is visible.');
#pragma warning restore
#endif
Assert.IsTrue(EmailEditor.Send.Enabled(), 'Send Action was not enabled.');
end;

Expand Down
Loading