NAV 2013 Mail - No New Line characters?

ShedmanShedman Member Posts: 194
edited 2012-12-18 in NAV Three Tier
Having upgraded my database to NAV2013, I had an issue with sending out my digital invoices. So checking out the new codeunit 397 - Mail, I have successfully modified my code to use the same coding that is used there.

So now I get my e-mail, with everything in it; to address, cc addresses, subject, attachment(s) and body text. So far so good.


The only thing I cannot get to work is new lines in the body text. Not with CR/LF characters, not with System.Environment.NewLine dotnet variable.
I use NAV2013 NL (build 33781) and 32-bit Outlook 2013.


Anyone got this working?

Answers

  • ara3nara3n Member Posts: 9,256
    char10 := 10;


    FORMAT(CH10) will give you a new line.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • ShedmanShedman Member Posts: 194
    Thanks for your tip Rashed. Unfortunately it doesn't work.

    I have added Char13, Char10 and a dotnet newline, but still I don't get new lines in my e-mail :(
    CharLineBreak := 10;
    LineBreak := FORMAT(CharLineBreak);
    CharLineBreak := 13;
    LineBreak := LineBreak + FORMAT(CharLineBreak);
    
    OutlookMessageHelper := OutlookMessageHelperInstance.OutlookMessage;
    
    ErrorNo := 0;
    
    //OSendMail.SentOnBehalfOfName := 'facturering@eqgroup.nl';
    OutlookMessageHelper.Recipients := ToName;
    OutlookMessageHelper.CarbonCopyRecipients := CCName;
    OutlookMessageHelper.Subject := Subject;
    OutlookMessageHelper.BodyFormat := 2;
    OutlookMessageHelper.ShowNewMailDialogOnSend := OpenDialog;
    
    FOR i := 1 TO ARRAYLEN(Body) DO BEGIN
      IF Body[i] <> '' THEN
        OutlookMessageHelper.Body.Append(Body[i]);
      OutlookMessageHelper.Body.Append(CharLineBreak);
      OutlookMessageHelper.Body.Append(DotnetEnviron.NewLine);
    END;
    
    FOR i := 1 TO ARRAYLEN(AttachFileNames) DO BEGIN
      IF AttachFileNames[i] <> '' THEN
        OutlookMessageHelper.AttachmentFileNames.Add(AttachFileNames[i]);
    END;
    
    OutlookMessageHelper.Send;
    

    The DotnetEnviron is a dotnet variable of type 'System.Environment.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089''
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    try with
    OutlookMessageHelper.BodyFormat := 1;
    
  • ShedmanShedman Member Posts: 194
    try with
    OutlookMessageHelper.BodyFormat := 1;
    
    Still no luck ...
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    I think you need to use LineBreak instead of CharLineBreak like below
    OutlookMessageHelper.Body.Append(LineBreak);
    
  • ShedmanShedman Member Posts: 194
    I think you need to use LineBreak instead of CharLineBreak like below
    OutlookMessageHelper.Body.Append(LineBreak);
    
    ](*,)

    Thanks, that did the trick!
Sign In or Register to comment.