Code unit 'Mail'

fezih5fezih5 Member Posts: 12
Hi all. Am sending customer statements by email to my clients. My Qs is about the body part of the email.

QS: I need to separate body texts in to paragraps. Am told reference codeunit MAIL.Function=AddBodyLine.

Now how do i manage this? Thanx
:?

Comments

  • kinekine Member Posts: 12,562
    If you are using SMTP mailing, you can send the mail as HTML and use '<br>' as end of line etc.

    In common mail you can try to add character '\' as a new line...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • MalajloMalajlo Member Posts: 294
    I'm using Microsoft CDO For Exchange 2000 Library.

    Try this, it is not last version, but you'll find out the way.
    PROCEDURE SendSMTP@1000000002(Sender@1000000000 : Text[50];From@1000000001 : Text[50];RcpTo@1000000002 : Text[50];Cc@1000000016 : Text[50];Bcc@1000000017 : Text[50];SMTPServer@1000000003 : Text[50];Subject@1000000004 : Text[150];HTMLBody@1000000005 : Variant;TextBody@1000000006 : Variant);
        VAR
          Mail@1000000015 : Automation "{CD000000-8B95-11D1-82DB-00C04FB1625D} 1.0:{CD000001-8B95-11D1-82DB-00C04FB1625D}:'Microsoft CDO For Exchange 2000 Library'.Message";
          Config@1000000014 : Automation "{CD000000-8B95-11D1-82DB-00C04FB1625D} 1.0:{CD000022-8B95-11D1-82DB-00C04FB1625D}:'Microsoft CDO For Exchange 2000 Library'.IConfiguration";
          Fields@1000000013 : Automation "{00000205-0000-0010-8000-00AA006D2EA4} 2.5:{00000564-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.5 Library'.Fields";
          Field@1000000012 : Automation "{00000205-0000-0010-8000-00AA006D2EA4} 2.5:{00000569-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.5 Library'.Field";
          ItemIndex@1000000008 : Variant;
          ItemVal@1000000007 : Variant;
        BEGIN
          CLEARALL ;
          IF ISCLEAR(Mail) THEN CREATE(Mail) ;
          Config := Mail.Configuration ;
    
          Fields := Config.Fields ;
          ItemIndex := 'http://schemas.microsoft.com/cdo/configuration/SendUsing' ;
          ItemVal := '2' ;
          Field := Fields.Item(ItemIndex) ;
          Field.Value := ItemVal ;
    
          ItemIndex := 'http://schemas.microsoft.com/cdo/configuration/smtpserver' ;
          ItemVal := SMTPServer ;
          Field := Fields.Item(ItemIndex) ;
          Field.Value := ItemVal ;
          ItemIndex := 'http://schemas.microsoft.com/cdo/configuration/smtpserverport' ;
          ItemVal := '25' ;
          Field := Fields.Item(ItemIndex) ;
          Field.Value := ItemVal ;
          ItemIndex := 'http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout' ;
          ItemVal := '1' ;
          Field := Fields.Item(ItemIndex) ;
          Field.Value := ItemVal ;
    
          Fields.Update ;
    
          Mail.From := From ;
          Mail.Sender := Sender ;
          Mail."To" := RcpTo ;
          Mail.CC := Cc ;
          Mail.BCC := Bcc ;
          Mail.Subject := Subject ;
          IF NOT ISCLEAR(HTMLBody) THEN Mail.HTMLBody := HTMLBody
          ELSE Mail.TextBody := TextBody  ;
          Mail.Send ;
    
          CLEARALL ;
        END;
    

    I'm using this for notification of sucessfull import of exchange rates.
    IF CurrExchangeRate.INSERT THEN 
          BEGIN
            HTMLBody := HTMLBody + '<b>' + CurrExchangeRate."Currency Code" + '</b>(' +CurrExchangeRate.ISO+') - 1 EUR='+
             FORMAT( CurrExchangeRate."Exchange Rate Amount" ) + '<p>' ;
          END ;
    
    ...
    ...
    
    SendSMTP('me','me@company.si','cc@company.si','me@company.si','',
      'mail.company.si','Exchange rates for '+FORMAT(CurrExchangeRate."Starting Date")+' are imported'),HTMLBody,'') ;
    
Sign In or Register to comment.