Error in Mail sending from 397

PradeepMindshellInfoPradeepMindshellInfo Member Posts: 13
I am working with Navision 9 SP1.
Targeted work:- Auto PDF Generation and Mail the generated PDF file.

--> PDF is generating Successfully.
--> But when i trying to mail this PDF. Its shows the following error.

Microsoft Dynamics NAV Classic
Boolean must not be blank.

Boolean is missing or invalid in the expression.

OK

Note :- In this code i am using Code unit 397..

Cust.RESET;
Cust.SETRANGE("No.","Sell-to Customer No.");
IF Cust.FIND('-') THEN BEGIN
Cust.TESTFIELD(Cust."E-Mail");
IF Cust."E-Mail" <> '' THEN BEGIN
EmailBody[1]:='Dear '+"Bill-to Contact"+',';
EmailBody[2]:='I am sending the Sales Quote. Please find the attachment.';
EmailBody[3] := 'With Regards,';
EmailBody[4] := 'Satyam Tayal';

Lf[1] := 13;
Lf[2] := 10;
Mail.AddBodyline(EmailBody[1]);
Mail.AddBodyline(Lf);
Mail.AddBodyline(EmailBody[2]);
Mail.AddBodyline(Lf);
Mail.AddBodyline(Lf);
Mail.AddBodyline(Lf);
Mail.AddBodyline(Lf);
Mail.AddBodyline(EmailBody[3]);
Mail.AddBodyline(Lf);
Mail.AddBodyline(EmailBody[4]);

Mail.NewMessage(Cust."E-Mail",'','Quotation Report','','C:\PDF\'+"No."+'.PDF',TRUE);
Mail.Send();

//MESSAGE('%1',Test);
END;
END ELSE
MESSAGE('File not found')

will any body suggest me what i have to do????
If someone suggest me to use codeunit 400 instead of 397.
Please specify me reason for this.



Thanks in advance.

Pradeep Kumar
Regards
Pradeep Bhardwaj

Comments

  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Did you try to assign this statement to a boolean?

    like Result := Mail.Send();

    Send function might be returning boolean..please check CU397 send functionn
  • PradeepMindshellInfoPradeepMindshellInfo Member Posts: 13
    After ur suggesion i have corrected it. But again i am getting same error.

    Microsoft Dynamics NAV Classic
    Boolean must not be blank.

    Boolean is missing or invalid in the expression.

    OK

    Mail.AddBodyline(Lf);
    Mail.AddBodyline(EmailBody[3]);
    Mail.AddBodyline(Lf);
    Mail.AddBodyline(EmailBody[4]);

    Mail.NewMessage(Cust."E-Mail",'','Quotation Report','','C:\PDF\'+"No."+'.PDF',TRUE);
    :-# Test:=Mail.Send();

    //MESSAGE('%1',Test);
    END;
    END ELSE
    MESSAGE('File not found')
    Regards
    Pradeep Bhardwaj
  • BernardJBernardJ Member Posts: 57
    I am not sure why this function "Send" is available in cu 397. The function "NewMessage" already comprises this line of code:
    MailSent := OSendMail.Send;
    

    You could try to omit your line "Mail.Send();"
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Enable the debugger so you can see which line causes the error.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
Sign In or Register to comment.