REG SMTP MAILS

Hi,All

I am trying to send the Mail through nav code mails are sending , but attachment is not attaching wen i writing the follow code

SalesLine.RESET;
SalesLine.SETRANGE(“Document No.”,“No.”);
IF SalesLine.FINDSET THEN;
SMTPMail.CreateMessage(’’,‘sairam@b2bsoftech.com’,‘sairam@b2bsoftech.com’,
‘’,’’,FALSE);
SMTPMail.AddCC(‘sairam@b2bsoftech.com’);
SMTPMail.AddBCC(‘sairam@b2bsoftech.com’);
SMTPMail.AppendBody(‘Dear Sir / Madam,\Please find below the Product wise dispatch report on ‘+FORMAT(“Posting Date”)
+’.’+‘InvoicNo. ‘+“No.”+‘Customer PO No’+“Customer Order No.”+’.’+’\The Details of which are attached’ +’.’);
REPORT.SAVEASEXCEL(50243,‘D:\SAI\dispatch.xls’);
IF EXISTS(‘D:\SAI\Dispatch.xls’) THEN BEGIN
SMTPMail.AddAttachment(‘D:\SAI\Dispatch.xls’);
SMTPMail.Send;
END;

and i want to print the message in next line like

Dear sir,

please find the dispatch details

but wen i writing above code using appendbody function the message is not printing in the next line.please help me on this .

Add SLEEP(5000) after

REPORT.SAVEASEXCEL(50243,‘D:\SAI\dispatch.xls’);

no same problem attachment is not attching.

Hi

Maybe there is very little execution time between creation of file, Sending it as Attachment and Deleting it. The File System may not be claring the Handles to the File.

So you can use the SLEEP(value in millisecs) function to put some delay. Try using Sleep befor smtp.attachment function and after smtp.send function.

+++++++
sleep(30000)
SMTPMail.AddAttachment(AttachFile);
SMTPMail.Send();
sleep(30000);

thanks it is ok now .

But some small problem is there in this here mails are sending but the body is appearing as below

“Dear Sir,Please find the attachment details of dispatch” like this

but i want the following format

Dear sir

Please find the attachmnt

Like above means i want please find the attachment details in next line i wrote ‘’ this before please find but it wont work please guide me on this.

Hi sai

Declare two char variables

Lcha1:=10;
Lcha2:=13;

SMTPMail.AppendBody(‘Dear Sir,’**+Lcha1+Lcha2+’**Please find the attachment details of dispatch’ );