While running codeunit its sending all customer statement as pdf .not only specific customer.
if i use setrange filter 1img error come.
with filter sending email with all customer report not specific.
While running codeunit its sending all customer statement as pdf .not only specific customer.
if i use setrange filter 1img error come.
with filter sending email with all customer report not specific.
Hello,
You are exporting the Image to FileName and in the email Attachment you have used FilePath variable that's why you are not getting the attachment.
***I recommended you to sending email with attachment use the stream attachment.
I have used the stream as shown below and it works, Stream will increase the performance because you do not required additional tasks
like inserting in temp blob and exporting again.
LOCAL SendMailWithAttachment() //function name //>>BKS 07.18.20 T409.GET; WITH CU400 DO BEGIN CreateMessage( 'Auto Service', T409."User ID", //Sender Address T409."Test Mail ID", //Recipients Address STRSUBSTNO(Sub, TODAY), //Subject 'Hello All,', TRUE ); AppendBody('
'); AppendBody(STRSUBSTNO('Please ignore the email as it was testing by %1.', USERID)); AppendBody('
'); AppendBody('Regards,'); AppendBody('
'); AppendBody('Auto Service'); AppendBody('
'); AppendBody('
'); AppendBody('This is a system generated mail. Please do not reply to this mail id'); //Attachment CompanyInformation.GET; CompanyInformation.CALCFIELDS(Picture); IF CompanyInformation.Picture.HASVALUE THEN BEGIN CompanyInformation.Picture.CREATEINSTREAM(PicInStream); AddAttachmentStream(PicInStream,'Company Picture.png'); END; Send; END; //<
i use this code for send company logo in email but its send blank image plzhelp
Hello Abhishek,
See the below code for your reference, this code is working for me.
SendCSMail is a function with simple code which will send email for each customer.
if you are using Report 116 then use filter as per your report, I have used Report 10072.
CustomerStatement.InitializeRequest is a custom function to initialize the request page of the report.
LOCAL SendCustomerStmt() WITH CustomerG DO BEGIN RESET; SETFILTER("No.", '3|100|100182|100676'); Customer number filters SETRANGE(Blocked, Blocked::" "); NewPrintEntriesDue := TRUE; NewPrintAllHavingBal := TRUE; NewPrintCompany := TRUE; NewPrintRemitTo := TRUE; NewUpdateNumbers := TRUE; NewStatementStyle := NewStatementStyle::"Open Item"; NewAgingMethod := NewAgingMethod::"Trans Date"; NewStartDate := CALCDATE('-CM',TODAY); EVALUATE(NewPeriodCalculation, ''); IF FINDSET THEN BEGIN REPEAT CustomerL.RESET; CustomerL.SETRANGE("No.", "No."); CustomerL.FINDFIRST; CLEAR(CustomerStatement); //Report 10072 CLEAR(FileNameL); CustomerStatement.SETTABLEVIEW(CustomerL); CustomerStatement.USEREQUESTPAGE(FALSE); CustomerStatement.InitializeRequest( NewPrintEntriesDue, NewPrintAllHavingEntry, NewPrintAllHavingBal, NewUpdateNumbers, NewPrintCompany, NewPrintRemitTo, NewStatementStyle, NewAgingMethod, NewPeriodCalculation, NewLogInteraction, NewChosenOutputMethod, NewPrintRemaining, NewStartDate ); AttachmentFileWithPath := Path CustomerL."No." '.pdf'; //Attachment File Name IF CustomerStatement.SAVEASPDF(AttachmentFileWithPath) THEN BEGIN IF FileManagement.ServerFileExists(AttachmentFileWithPath) THEN BEGIN IF NOT RemoveEmptyFile(AttachmentFileWithPath) THEN SendCSMail(AttachmentFileWithPath, ToAddressL, CS_Subject); END; END; UNTIL NEXT = 0; END; END;
André Arnaud de Cal...
292,516
Super User 2025 Season 1
Martin Dráb
231,403
Most Valuable Professional
nmaenpaa
101,156