How to send mail with outlook from NAV5.0 on a button click

Hi all

I have a form with some values. I need to send mail through outlook when i click on a button
name send mail.

My mail format is like this:

To - subedar.ali@abc.com
subject - revenue

Body -
Revenue : 40000.
RBs : 3000.
total : 7000.

Comments

  • did you check the source behind the mail button on the, for example, customer card?
    Do you make it right, it works too!
  • garak wrote:
    did you check the source behind the mail button on the, for example, customer card?

    Thanks for reply

    yes i have with the code like this on mail button


    Recipients := 'punit.sharma@abc.com,subedar.ali@abc.com';
    Mail.MailContCustVendBank(DATABASE::Customer,'BRSC00019',Recipients);

    This is working fine, but here how can i manage my other values in mail body.


    I want to use this code


    SenderName := 'subedar.ali@abc.com';
    SenderAddress := 'brijendra.singh@abc.com';
    Recipients := 'punit.sharma@abc.com';
    Subject := 'Please see the mail its imp';
    In Body
    'Total Employe :20
    revenue :4000


    SMTPMail.CreateMessage(SenderName,SenderAddress,Recipients,Subject,Body,HtmlFormatted);

    i want to use this code ,even i am not getting any error but still i am anable to send mail

    Plz help
  • First thing is to check that SMTP server is setup correctly in form 409 (SMTP Mail Setup).

    Then using codeunit 400 (SMTP Mail), the basic syntax goes something like this:
    SMTP.CreateMessage (‘My Name’,'fromemailaddress@somedomain.com','tosomeone@thierdomain.com',’Subject’,’Body’,TRUE); <-- This creates the message and allows a simple subject to be specified (subject) and a short body message (1024 characters if you modify the string lengths).
    however, I use this for the body text:
    SMTP.AppendBody('your text here'); <-- You can repeat this as many times as needed.
    And lastly to send the email:
    SMTP.Send;
    Now, as this can use HTML format for the email (The "TRUE" bit of the SMTP.CreateMessage) you can format the email with HTML tags, so on our system I created a number of Text Constants (as below):
    Name ConstValue
    HTMLNewLine <br>
    HTMLNewParagraph <p>
    FONTVerdana2 <FONT FACE="Verdana" SIZE="2">
    FONTBold <b>
    FONTBoldOff </b>
    FONTItalicON <i>
    FONTItalicOFF </i>
    FONTUnderlineON <u>
    FONTUnderlineOFF </u>

    If you have a look at codeunit 400 you will see most of this and more functions for you to use :D

    Dean.
    Remember: Keep it simple