Hi
I use the sendmail function to send a mail with an attachment.
Since the name of the attachment is different from time to time, i use a variable to save the path and name of the file, in stead of writing it directly in the sendmail function.
My problem is that whenever i have a file, where the name (-path & -type) is longer than 8 characters, it's not always send.
It's send the first time, but then i have to shorten the filename to 8 characters or less and send a mail, before i again can send a file with a filename, there is longer than 8 characters.
Attachment in mail
I use version 2.10e
It always send an e-mail with the filename used in the code. But i would like to use a filename like 'c:\SalesShipment' + "No." + '.pdf', but even 'c:\salesshipment.pdf' fails.
I make the call from a table:
FileName := 'c:\salesshi.pdf';
createPDF.initPDF('', FileName,'','');
createPDF.RUN;
REPORT.RUNMODAL(ReportSelection."Report
ID",FALSE,FALSE,SalesShptHeader);
SalesShptHeader.FIND('-');
contcust.SETRANGE("No.", SalesShptHeader."Sell-to Customer No.");
contcust.SETRANGE("Link to Table", contcust."Link to Table"::Customer);
IF contcust.FIND('-') THEN BEGIN
IF NOT contact.GET(contcust."Contact No.") THEN
ERROR(Text002);
END ELSE
ERROR(Text002);
Subject := 'Sales Shipment ' + "No.";
Body := 'Vedlagt er Sales Shipment ' + SalesShptHeader."No.";
createPDF.initPDF(contact."E-Mail",'',Body,Subject);
createPDF.RUN;
CLEAR(createPDF);
Here is the codeunit that creates and send the PDF file:
OnRun()
IF contactmail = '' THEN
prePDF
ELSE
postPDF;
initPDF(mail : Text[100];filename : Text[250];body : Text[250];subject : Text[250])
contactmail := mail;
IF filename <> '' THEN
name := filename;
IF subject <> '' THEN
subjectmail := subject;
IF body <> '' THEN
bodymail := body;
prePDF()
pdfConverter.DriverInit('Amyuni PDF Converter');
pdfConverter.EnablePrinter(LicenseName,LicenseKey);
pdfConverter.DefaultDirectory := 'c:\';
pdfConverter.FileNameOptions := 1+2;
pdfConverter.DefaultFileName := name;
pdfConverter.SetDefaultPrinter;
postPDF()
pdfConverter.RestoreDefaultPrinter;
pdfConverter.DriverEnd;
IF CONFIRM('Send genereret fil til email:'+contactmail,FALSE) THEN
pdfConverter.SendMail(contactmail,'','',subjectmail,bodymail,name,0);
contactmail := '';
CLEAR(pdfConverter);
It always send an e-mail with the filename used in the code. But i would like to use a filename like 'c:\SalesShipment' + "No." + '.pdf', but even 'c:\salesshipment.pdf' fails.
I make the call from a table:
FileName := 'c:\salesshi.pdf';
createPDF.initPDF('', FileName,'','');
createPDF.RUN;
REPORT.RUNMODAL(ReportSelection."Report
ID",FALSE,FALSE,SalesShptHeader);
SalesShptHeader.FIND('-');
contcust.SETRANGE("No.", SalesShptHeader."Sell-to Customer No.");
contcust.SETRANGE("Link to Table", contcust."Link to Table"::Customer);
IF contcust.FIND('-') THEN BEGIN
IF NOT contact.GET(contcust."Contact No.") THEN
ERROR(Text002);
END ELSE
ERROR(Text002);
Subject := 'Sales Shipment ' + "No.";
Body := 'Vedlagt er Sales Shipment ' + SalesShptHeader."No.";
createPDF.initPDF(contact."E-Mail",'',Body,Subject);
createPDF.RUN;
CLEAR(createPDF);
Here is the codeunit that creates and send the PDF file:
OnRun()
IF contactmail = '' THEN
prePDF
ELSE
postPDF;
initPDF(mail : Text[100];filename : Text[250];body : Text[250];subject : Text[250])
contactmail := mail;
IF filename <> '' THEN
name := filename;
IF subject <> '' THEN
subjectmail := subject;
IF body <> '' THEN
bodymail := body;
prePDF()
pdfConverter.DriverInit('Amyuni PDF Converter');
pdfConverter.EnablePrinter(LicenseName,LicenseKey);
pdfConverter.DefaultDirectory := 'c:\';
pdfConverter.FileNameOptions := 1+2;
pdfConverter.DefaultFileName := name;
pdfConverter.SetDefaultPrinter;
postPDF()
pdfConverter.RestoreDefaultPrinter;
pdfConverter.DriverEnd;
IF CONFIRM('Send genereret fil til email:'+contactmail,FALSE) THEN
pdfConverter.SendMail(contactmail,'','',subjectmail,bodymail,name,0);
contactmail := '';
CLEAR(pdfConverter);