Sending email from Quote ??

pskannaapskannaa Member Posts: 138
Hi,
Im using NAV 4.0, I want to send email through Quote card..

place on button 'Send eMail', when i click the button i need to send the quote details..

Question is i do not want to see the outlook screen, once i click the button it should be automatically attached the Quote details with 'To' address(capture from 'sell to customer' email address) and send it. Client is using Outlook2003

Is there any configuration required in code using(397) ??

Suggestion Please !!!

Thanks & Regards,
Psk

Comments

  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Use false in the last parameter of NewMessage function of CU397
  • pskannaapskannaa Member Posts: 138
    Thanks,

    How can i attach the Quote details ??? can you plz let me know which is the right way to sending the Quote details to customer !!!!
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    As per my knowlwdge save the report in system and attach to mail and send
  • pskannaapskannaa Member Posts: 138
    Is there any way to create PDF file and attached it automatically if i click 'Send mail' button.

    Second, if i generating the file manually for attachment, how do i attach the file while calling 'NewMessage' function ???
    because the 'Attachement' parameter is TEXT type, how can i specify the file/file path which i can send for attachment ??
    assume i hav the file in 'C:\Quote.pdf'
  • DivyaDivya Member Posts: 125
    I think it is possible.. if u see in the Vendor/Customer card --> Near E-Mail text box --> Email button is available.. U can use same coding to open new message in the Outlook..

    Mail (397) Codeunit is available in navision. There many codings has been written for each properties in Outlook. Just look into it whether u can use same coding or some additional coding required...
    Victory is sweetest when you've known defeat
  • DivyaDivya Member Posts: 125
    Ur already using same codeunit.... Attachment parameter type is text.. so u have to give path there...
    Victory is sweetest when you've known defeat
  • DivyaDivya Member Posts: 125
    Victory is sweetest when you've known defeat
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    to print the report in pdf format, u need pdf converter in ur system or server
    in that u vl specify the path wre u want to save the re[ort

    give the same path in newmesage function
  • JPHSCJPHSC Member Posts: 67
    if you want to send it automatically, take a look at codeunit 400. It's much faster then outlook automation...

    Mail.CreateMessage(MyName,MyEmailAddress,reciep@to.com,Quote,'See Attachement',HtmlFormatted);
    Mail.AddAttachment('MyFreshlyPrintedPDF.pdf');
    Mail.Send;
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    JPHSC wrote:
    if you want to send it automatically, take a look at codeunit 400. It's much faster then outlook automation...

    Mail.CreateMessage(MyName,MyEmailAddress,reciep@to.com,Quote,'See Attachement',HtmlFormatted);
    Mail.AddAttachment('MyFreshlyPrintedPDF.pdf');
    Mail.Send;

    for this we need to set SMTP setup
  • jlandeenjlandeen Member Posts: 524
    There are lots of different options to send it - you can custom code using both the Mail (I think codeunit 397) and SMTP (codeunit 400) codeunits and implement a PDF print engine. PDF Exchange is one that I've used in the past and it has a programming API that you can hook into.

    There is also a packaged solution for PDF and mail by Altus (see: http://www.altusbusinesssolutions.com/) which allows you to fax and email from multiple areas in NAV.
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • JPHSCJPHSC Member Posts: 67
    edited 2009-04-08
    Also take a look at PDFCreator ...

    To get you started :
    Here is the code I use for PDF Creator :


    IF ISCLEAR(PDFCreator) THEN
    CREATE(PDFCreator);
    IF PDFCreator.cStart('/NoProcessingAtStartup',TRUE) = FALSE THEN
    ERROR('FOUT');
    IF PrintOption = PrintOption::Mail THEN BEGIN // Save it automatically ...
    PDFCreator.cOption('UseAutosave', 1);
    PDFCreator.cOption('UseAutosaveDirectory', 1);
    PDFCreator.cOption('AutosaveDirectory', vPath);
    PDFCreator.cOption('AutosaveFormat', 0);
    PDFCreator.cOption('AutosaveFilename', vFileName);
    END ELSE BEGIN // Use Pop up to save to file
    PDFCreator.cOption('UseAutosave', 0);
    PDFCreator.cOption('UseAutosaveDirectory', 0);
    END;
    varDefaultPrinter := PDFCreator.cDefaultPrinter;
    PDFCreator.cDefaultPrinter := 'PDFCreator';
    PDFCreator.cClearCache();
    PDFCreator.cPrinterStop := FALSE;

    Report.Runmodal(Report, FALSE, FALSE, Record);
    PDFCreator.cDefaultPrinter := varDefaultPrinter;
    Clear(PDFCreator);
  • pskannaapskannaa Member Posts: 138
    Thanks for suggestion...

    Big doubt , for creating automaic pdf file while clicking 'send email' button on quote form.

    where do i place the code link below
    See this link to Print PDF File...
    http://www.mibuso.com/forum/viewtopic.p ... DF+creator


    :whistle:
  • JPHSCJPHSC Member Posts: 67
    on push of button ( or you can put it in a function and use it to print to PDF .. . )

    lets say that the salesperson on the quote sends the mail
    SalesHeader := Rec;
    SalesHeader.SETRECFILTER;
    PrintOption := PrintOption::Mail;
    
    vPath := TemporaryPath;
    vFileName := SalesHeader."No." + '.pdf';
    
    Customer.GET(SalesHeader."Sell-To-Cust");
    IF Customer."E-Mail" = '' THEN 
      Error('No Email');
    
    SalesPerson.GET(SalesHeader."SalesPerson Code");
    IF SalesPerson."E-Mail" = '' THEN 
      Error('No Email');
    
    IF ISCLEAR(PDFCreator) THEN
    CREATE(PDFCreator);
    IF PDFCreator.cStart('/NoProcessingAtStartup',TRUE) = FALSE THEN
    ERROR('FOUT');
    IF PrintOption = PrintOption::Mail THEN BEGIN // Save it automatically ... 
    PDFCreator.cOption('UseAutosave', 1);
    PDFCreator.cOption('UseAutosaveDirectory', 1);
    PDFCreator.cOption('AutosaveDirectory', vPath);
    PDFCreator.cOption('AutosaveFormat', 0);
    PDFCreator.cOption('AutosaveFilename', vFileName);
    END ELSE BEGIN // Use Pop up to save to file
    PDFCreator.cOption('UseAutosave', 0);
    PDFCreator.cOption('UseAutosaveDirectory', 0);
    END;
    varDefaultPrinter := PDFCreator.cDefaultPrinter;
    PDFCreator.cDefaultPrinter := 'PDFCreator';
    PDFCreator.cClearCache();
    PDFCreator.cPrinterStop := FALSE;
    
    Report.Runmodal(Report::"your quote report", FALSE, FALSE, SalesHeader);
    PDFCreator.cDefaultPrinter := varDefaultPrinter;
    Clear(PDFCreator);
    
    If PrintOption = PrintOption::Mail THEN BEGIN
      Mail.CreateMessage(SalesPerson.Name, SalesPerson."E-mail", Customer."E-Mail", FORMAT("Salesheader.Document Type") + ' ' + SalesHeader."No", 
                                 'In attachement your requested ' + FORMAT("Salesheader.Document Type"),   FALSE);
      Mail.AddAttachement(vPath + vFileName);
      Mail.Send;
    ERASE(vPath + vfileName);
    END;
    

    Something like this should do the trick
  • pskannaapskannaa Member Posts: 138
    YES, i understand.

    but how to declare the variable "PDFCreator", Which type / Class ??

    i couldn't find any class in "Adobe Acrobat 8.0 Type Library" in type 'Automation'

    Can you plz let me know the DECLARATION OF 'PDFCreator' variable ???
  • JPHSCJPHSC Member Posts: 67
    hmmz :
    you download and install PDFCreator http://www.pdfforge.org/products/pdfcreator
    then you can find it between the automation variables ...
  • pskannaapskannaa Member Posts: 138
    Great Buddy !!

    Excellent, Working Fine.

    Can you plz suggest me How to send the same "Report " to FAX ???
  • JPHSCJPHSC Member Posts: 67
    You will have to use some kind of fax software. I know we used GFI Faxmaker in the past... But I couldn't say what is good and wath isn't

    Set the topic to solved
  • pskannaapskannaa Member Posts: 138
    Thx,

    Reg; Mail:

    I used code unit:397,

    In case if i need to set SMPT then which code unit i can choose, as per ur ref: i couldn't find Code Unit :400 in NAV 4.0

    Wht is the alternative?
  • JPHSCJPHSC Member Posts: 67
    Upgrading to 5 :lol:
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    pskannaa wrote:
    Thx,

    Reg; Mail:

    I used code unit:397,

    In case if i need to set SMPT then which code unit i can choose, as per ur ref: i couldn't find Code Unit :400 in NAV 4.0

    Wht is the alternative?

    SMTP function is added in 5.0
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    I think we can try this by importing SMTP objects from 5.0 to 4.0.

    i havenot tried this.

    DO this by taking suggetions from any one who has done before
  • pskannaapskannaa Member Posts: 138
    #-o

    Is there any posibility to copy the respected DLL and register it in NAV 4.0 ???

    and wht is the alternative other than installing 5 ver. Because some time mail is not sending when i m using Outlook(code unit:397)
  • pskannaapskannaa Member Posts: 138
    My problem is, it's strucking on sending email through Outlook(Codeunit: Mail)

    when i send the email with pdf attach...mail will be sitting on the outlook 'DRAFT', not been sent to the receipnt.

    I use the code:
    bMailSent := cSendmail.NewMessage(sToID,sCCID,sSubject,sBody,sAttachPath + sAttachFile,FALSE);

    I don't know y it is not sending with attach pdf. is any wait option is required or else any key hav to set !!!

    Second, After sending the mail 'PDF creater' is running, so i couldn't access the NAV screen, once i close it through task bar icon(right click) then i can access NAV.
    If i put the code "PDFCreator.cClose" after sending mail, throwing error 'Automation variable not been instantiated ...' something like...
Sign In or Register to comment.