On Post of sales order an email has to be sent to the customer with attachment of the order, while i do that i get the following error
The SMTP Mail system returned the following error : A recipient must be specified
The following is the code I used
SendEmailWithAttachment(CustNo : Code[20])
Customer.RESET;
Customer.SETRANGE("No.",SalesHeader."Sell-to Customer No.");
IF Customer.FINDFIRST THEN
CustEmail:=Customer."E-Mail";
SMTPMailSetup.GET;
FileName:=FileManagement.ServerTempFileName('pdf');
//FileName:=SMTPMailSetup."Path to Save Reports"+'Statement'+'.pdf';
REPORT.SAVEASPDF(205,FileName,SalesHeader);
SMTPMail.CreateMessage(SMTPMailSetup."Sender Name",SMTPMailSetup."User ID",CustEmail,'Sales Order','',TRUE);
SMTPMail.AddAttachment(FileName,SalesHeader."Sell-to Customer No."+'.pdf');
SMTPMail.AppendBody('Dear Sir');
SMTPMail.AppendBody('<br><br>');
SMTPMail.AppendBody('Please find the attachment');
SMTPMail.AppendBody('<br><br>');
SMTPMail.Send;
MESSAGE('Mail send to Customer');