Mail Management, line break

philippegirodphilippegirod Member Posts: 191
Hi all,
Probably an already answered question but i didn't find the answer.

I want to send an email from a form in Navision. In the record I've the body text of the message (text field).
But... I don't know how to obtain line breaks. I tried {enter}, <BR>, /n, \, nothing works.

Here is the code of the function call :
        MailMngt.NewMessage(SalesPersRec1."E-Mail",
                                       CCName,
                                       STRSUBSTNO(MailReportSetup."Mail Subject",TODAY,COMPANYNAME),
                                       BodyText,
                                       FileNameText,
                                       FALSE);

Here is an example of the content of Body text :
"Dear Mr nn {ENTER} <BR> {ENTER} <BR> \n \n Please find attached the Navision report for Company Cronus Ltd.<BR>{ENTER}This report has been calculated on 01/01/2001.{ENTER}<BR>{ENTER}<BR>Best Regards"

Any idea ?



Thank you a lot.
My candle burns by both ends, it will not last the night,
But oh my foes and oh my friends, it gives a lovely light

Comments

  • BBlueBBlue Member Posts: 90
    //Bogdan
  • sendohsendoh Member Posts: 207
    You can use Character ASCII 10.


    vchar is variable with datatype of char
    vbody is variable with datatype of text
    line1,line2,line3 is variable with datatype of text
    vChar := 10;

    vBody := line1 +format(vchar)+ line2 + format(vchar) + line3
    Sendoh
    be smart before being a clever.
  • sendohsendoh Member Posts: 207
    this is the example. just copy and paste on notepad and import it in your test DB.
    OBJECT Form 72009 SMTP Mail
    {
      OBJECT-PROPERTIES
      {
        Date=09/18/08;
        Time=[ 4:48:04 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=11770;
        Height=9130;
        OnOpenForm=BEGIN
                     vRecipients := 'enrique@acw-distribution.com.ph';
                   END;
    
      }
      CONTROLS
      {
        { 1000000000;CommandButton;9460;8250;2200;550;
                                                     HorzGlue=Right;
                                                     VertGlue=Bottom;
                                                     CaptionML=ENU=Send;
                                                     OnPush=BEGIN
                                                              SendingMail();
                                                            END;
                                                             }
        { 1000000010;CommandButton;7150;8250;2200;550;
                                                     HorzGlue=Right;
                                                     VertGlue=Bottom;
                                                     CaptionML=ENU=&Write Message;
                                                     OnPush=BEGIN
    
                                                              vMsg2 := CurrForm.SFrom.FORM.WriteMsg;
                                                              CurrForm.SFrom.ACTIVATE;
                                                            END;
                                                             }
        { 1000000015;SubForm;110  ;3410 ;11550;4510 ;Name=SFrom;
                                                     HorzGlue=Both;
                                                     VertGlue=Both;
                                                     SubFormID=Form72010 }
        { 1000000017;TabControl;110;110 ;11550;3190 ;HorzGlue=Both;
                                                     VertGlue=Top;
                                                     PageNamesML=ENU=General,Attachment }
        { 1000000003;TextBox;3630 ;990  ;7480 ;440  ;ParentControl=1000000017;
                                                     InPage=0;
                                                     SourceExpr=vRecipients }
        { 1000000008;Label  ;330  ;990  ;3300 ;440  ;ParentControl=1000000017;
                                                     InPage=0;
                                                     FontBold=Yes;
                                                     LeaderDots=Yes;
                                                     CaptionML=ENU=To }
        { 1000000004;TextBox;3630 ;1540 ;7480 ;440  ;ParentControl=1000000017;
                                                     InPage=0;
                                                     SourceExpr=vCC }
        { 1000000009;Label  ;330  ;1540 ;3300 ;440  ;ParentControl=1000000017;
                                                     InPage=0;
                                                     FontBold=Yes;
                                                     LeaderDots=Yes;
                                                     CaptionML=ENU=CC }
        { 1000000005;Label  ;330  ;2640 ;3300 ;440  ;ParentControl=1000000017;
                                                     InPage=0;
                                                     FontBold=Yes;
                                                     LeaderDots=Yes;
                                                     CaptionML=ENU=Subject }
        { 1000000011;Label  ;330  ;2090 ;3300 ;440  ;ParentControl=1000000017;
                                                     InPage=0;
                                                     FontBold=Yes;
                                                     LeaderDots=Yes;
                                                     CaptionML=ENU=BCC }
        { 1000000018;TextBox;3630 ;2090 ;7480 ;440  ;ParentControl=1000000017;
                                                     InPage=0;
                                                     SourceExpr=vBCC }
        { 1000000023;TextBox;3630 ;2640 ;7480 ;440  ;ParentControl=1000000017;
                                                     InPage=0;
                                                     SourceExpr=vRe }
        { 1000000019;TextBox;3630 ;1100 ;6930 ;440  ;ParentControl=1000000017;
                                                     InPage=1;
                                                     SourceExpr=vBody[1];
                                                     OnAssistEdit=BEGIN
                                                                    vBody[1] := cduCDialog.OpenFile('Attachment','',1,'',1);
                                                                  END;
                                                                   }
        { 1000000020;TextBox;3630 ;2200 ;6930 ;440  ;ParentControl=1000000017;
                                                     InPage=1;
                                                     SourceExpr=vBody[3];
                                                     OnAssistEdit=BEGIN
                                                                    vBody[3] := cduCDialog.OpenFile('Attachment','',1,'',1);
                                                                  END;
                                                                   }
        { 1000000021;TextBox;3630 ;1650 ;6930 ;440  ;ParentControl=1000000017;
                                                     InPage=1;
                                                     SourceExpr=vBody[2];
                                                     OnAssistEdit=BEGIN
                                                                    vBody[2] := cduCDialog.OpenFile('Attachment','',1,'',1);
                                                                  END;
                                                                   }
        { 1000000022;TextBox;3630 ;2750 ;6930 ;440  ;ParentControl=1000000017;
                                                     InPage=1;
                                                     SourceExpr=vBody[4];
                                                     OnAssistEdit=BEGIN
                                                                    vBody[4] := cduCDialog.OpenFile('Attachment','',1,'',1);
                                                                  END;
                                                                   }
        { 1000000012;Label  ;330  ;1100 ;3300 ;440  ;ParentControl=1000000017;
                                                     InPage=1;
                                                     CaptionML=ENU=Attach File }
        { 1000000013;Label  ;330  ;1650 ;3300 ;440  ;ParentControl=1000000017;
                                                     InPage=1;
                                                     CaptionML=ENU=Attach File }
        { 1000000014;Label  ;330  ;2200 ;3300 ;440  ;ParentControl=1000000017;
                                                     InPage=1;
                                                     CaptionML=ENU=Attach File }
        { 1000000016;Label  ;330  ;2750 ;3300 ;440  ;ParentControl=1000000017;
                                                     InPage=1;
                                                     CaptionML=ENU=Attach File }
      }
      CODE
      {
        VAR
          cduSMTPMail@1000000000 : Codeunit 400;
          cduCDialog@1000000007 : Codeunit 412;
          ok@1000000001 : Boolean;
          vSenderName@1000000002 : Text[50];
          vSenderAdd@1000000003 : Text[50];
          vRecipients@1000000004 : Text[1000];
          vRe@1000000005 : Text[100];
          vBody@1000000006 : ARRAY [5] OF Text[1024];
          i@1000000008 : Integer;
          vMsg@1000000009 : ARRAY [10] OF Text[102];
          vMsg2@1000000010 : Text[1024];
          vCC@1000000011 : Text[1000];
          vBCC@1000000012 : Text[1000];
          vCCTemp@1000000013 : Text[60];
          vBCCTemp@1000000014 : Text[60];
          vRecpTemp@1000000015 : Text[60];
    
        PROCEDURE SendingMail@1000000003();
        VAR
          recUserSetup@1000000000 : Record 91;
        BEGIN
            CLEAR(cduSMTPMail);
    
            recUserSetup.GET(USERID);
    
            IF recUserSetup."E-Mail" = '' THEN
              ERROR('Please Specify EMAIL address from User Setup table');
    
            vSenderName := USERID;
    
            vSenderAdd := recUserSetup."E-Mail";
    
            cduSMTPMail.CreateMessage(vSenderName,vSenderAdd,vRecipients,vRe,vMsg2,FALSE);
    
            IF vCC <> '' THEN
              cduSMTPMail.AddCC(vCC);
            IF vBCC <> '' THEN
              cduSMTPMail.AddBCC(vBCC);
    
            FOR i := 1 TO 4 DO BEGIN
              IF vBody[i] <> '' THEN
                cduSMTPMail.AddAttachment(vBody[i]);
            END;
    
            cduSMTPMail.Send;
    
            MESSAGE('Message Sent');
        END;
    
        BEGIN
        END.
      }
    }
    
    OBJECT Form 72010 SMTP Mail Subform
    {
      OBJECT-PROPERTIES
      {
        Date=09/18/08;
        Time=[ 4:47:05 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=11660;
        Height=11000;
      }
      CONTROLS
      {
        { 1000000000;TextBox;0    ;0    ;11660;440  ;Name=B1;
                                                     HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[1] }
        { 1000000001;TextBox;0    ;440  ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[2] }
        { 1000000002;TextBox;0    ;880  ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[3] }
        { 1000000003;TextBox;0    ;1320 ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[4] }
        { 1000000004;TextBox;0    ;1760 ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[5] }
        { 1000000005;TextBox;0    ;2200 ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[6] }
        { 1000000006;TextBox;0    ;2640 ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[7] }
        { 1000000007;TextBox;0    ;3080 ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[8] }
        { 1000000008;TextBox;0    ;3520 ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[9] }
        { 1000000009;TextBox;0    ;3960 ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[10] }
        { 1000000010;TextBox;0    ;8360 ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[20] }
        { 1000000011;TextBox;0    ;7920 ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[19] }
        { 1000000012;TextBox;0    ;7480 ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[18] }
        { 1000000013;TextBox;0    ;7040 ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[17] }
        { 1000000014;TextBox;0    ;6600 ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[16] }
        { 1000000015;TextBox;0    ;6160 ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[15] }
        { 1000000016;TextBox;0    ;5720 ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[14] }
        { 1000000017;TextBox;0    ;5280 ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[13] }
        { 1000000018;TextBox;0    ;4840 ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[12] }
        { 1000000019;TextBox;0    ;4400 ;11660;440  ;Name=B1;
                                                     HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[11] }
        { 1000000021;TextBox;0    ;10560;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[25] }
        { 1000000022;TextBox;0    ;10120;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[24] }
        { 1000000023;TextBox;0    ;9680 ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[23] }
        { 1000000024;TextBox;0    ;9240 ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[22] }
        { 1000000025;TextBox;0    ;8800 ;11660;440  ;HorzGlue=Both;
                                                     Editable=No;
                                                     SourceExpr=vMsg[21] }
      }
      CODE
      {
        VAR
          vMsg@1000000000 : ARRAY [25] OF Text[102];
          vNewLine@1000000001 : Char;
          vBigText@1000000002 : BigText;
    
        PROCEDURE WriteMsg@1000000002() : Text[1024];
        VAR
          retShell@1000000005 : Integer;
          vPathFile@1000000004 : Text[30];
          TempFile@1000000003 : File;
          vIStreamDesc@1000000002 : InStream;
          r@1000000001 : Integer;
          vMsg2@1000000000 : Text[1024];
        BEGIN
    
            vNewLine := 10;
            vPathFile := 'C:\Message.htm';
            IF NOT TempFile.OPEN(vPathFile) THEN
              TempFile.CREATE(vPathFile);
    
            TempFile.CLOSE;
    
             retShell := SHELL(ENVIRON('windir') + '\notepad.exe', vPathFile);
    
            IF NOT TempFile.OPEN(vPathFile) THEN
              TempFile.CREATE(vPathFile);
    
            TempFile.CREATEINSTREAM(vIStreamDesc);
    
              FOR r:= 1 TO 25 DO BEGIN
                vIStreamDesc.READTEXT(vMsg[r],102);
                IF vMsg[r] <> '' THEN
                  vMsg2 += vMsg[r]+FORMAT(vNewLine);
              END;
    
            CurrForm.UPDATE;
    
            TempFile.CLOSE;
    
            EXIT(vMsg2);
        END;
    
        BEGIN
        END.
      }
    }
    
    Sendoh
    be smart before being a clever.
  • philippegirodphilippegirod Member Posts: 191
    Thanks, it works fine with the next code :
            //chr = var char
            chr := 13; 
            BodyText := CONVERTSTR(BodyText,'\',FORMAT(chr));
    
    My candle burns by both ends, it will not last the night,
    But oh my foes and oh my friends, it gives a lovely light
Sign In or Register to comment.