Attach multiple files - Send to Email - Business Central

rsrnavrsrnav Member Posts: 6
I'm using NAV Send Email on Sales Order, now how can we attach mulpile files here.
the files stored in Media Type on Document,

Using File Management BLOBExport function able to download file but needs to attach on mail automatically?

Answers

  • TallyHoTallyHo Member Posts: 339
    edited 2020-02-27
    I use this subscriber to unzip the attachment and add unzipped files before sending. But I guess you can add anything here.

    LOCAL [EventSubscriber] C260OnBeforeSendEmail(VAR TempEmailItem : TEMPORARY Record "Email Item";VAR IsFromPostedDoc : Boolean;VAR PostedDocNo : Code[20];VAR HideDialog : Boolean;VAR ReportUsage : Integer)
    IF NOT IsFromPostedDoc THEN
    EXIT;
    IF (UPPERCASE(FileManagement.GetExtension(TempEmailItem."Attachment File Path")) = 'ZIP') THEN BEGIN
    FileManagement.ExtractZipFileAndGetFileList(TempEmailItem."Attachment File Path",NameValueBuffer);
    NameValueBuffer.SETRANGE(ID,1,7);
    IF NameValueBuffer.FINDSET THEN BEGIN
    REPEAT
    CASE NameValueBuffer.ID OF
    1:
    BEGIN
    TempEmailItem."Attachment File Path" := NameValueBuffer.Name;
    TempEmailItem."Attachment Name" := FileManagement.GetFileName(NameValueBuffer.Name);
    END;
    2:
    BEGIN
    TempEmailItem."Attachment File Path 2" := NameValueBuffer.Name;
    TempEmailItem."Attachment Name 2" := FileManagement.GetFileName(NameValueBuffer.Name);
    END;
    3:
    BEGIN
    TempEmailItem."Attachment File Path 3" := NameValueBuffer.Name;
    TempEmailItem."Attachment Name 3" := FileManagement.GetFileName(NameValueBuffer.Name);
    END;
    4:
    BEGIN
    TempEmailItem."Attachment File Path 4" := NameValueBuffer.Name;
    TempEmailItem."Attachment Name 4" := FileManagement.GetFileName(NameValueBuffer.Name);
    END;
    5:
    BEGIN
    TempEmailItem."Attachment File Path 5" := NameValueBuffer.Name;
    TempEmailItem."Attachment Name 5" := FileManagement.GetFileName(NameValueBuffer.Name);
    END;
    END;
    UNTIL (NameValueBuffer.NEXT <= 0);
    END;
    END;
  • rsrnavrsrnav Member Posts: 6
    Hi

    In my case i have stored file as media in table, i have used the same subscriber ,but how to save this media as file and return file path to use as attachment in email item?
Sign In or Register to comment.