HTML in Body Email

angelsgepeangelsgepe Member Posts: 4
Hi everyone,

I want to send an email with a html file in the body.
I created the html file with a function of the report but I don't know what can I do to attach the html as a BODY email.

Thanks!!!

Angels

Comments

  • XypherXypher Member Posts: 297
    What E-mail Automation are you using?
  • nunomaianunomaia Member Posts: 1,153
    You can send e-mails in Navision using many components. Can you tell witch components you are using? It’s standard object to send e-mails in NAV 5?
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
  • XypherXypher Member Posts: 297
    nunomaia wrote:
    You can send e-mails in Navision using many components. Can you tell witch components you are using? It’s standard object to send e-mails in NAV 5?

    I wasn't asking him/her to help me out. I was asking because different components allow/disallow HTML formating and require different properties to be called with different values that may not be obvious. :mrgreen:

    angelsgepe wrote:
    Hi everyone,

    I want to send an email with a html file in the body.
    I created the html file with a function of the report but I don't know what can I do to attach the html as a BODY email.

    Thanks!!!

    Angels

    If I may suggest, you might want to look into using a PDF "printer" (PDFCreator is a good one) to convert your reports to PDF and attach to your emails. (So that the report being sent retains its format and doesn't get all misaligned and nasty looking.)

    (PDFCreator Example shown by ara3n: http://www.mibuso.com/forum/viewtopic.php?t=18331&highlight=)
  • angelsgepeangelsgepe Member Posts: 4
    Hi!!!

    I cann't attach the file. I must put it in the body.

    I'm using the standard components in Navision to do this.

    Thank you very much,

    Angels
  • XypherXypher Member Posts: 297
    So you're using CodeUnit: 397 (NAV<=4) or 400 (NAV5) ?
  • angelsgepeangelsgepe Member Posts: 4
    Hi,

    I don't use anything yet because I don't know what can I do this.

    Thanks,

    Angels
  • XypherXypher Member Posts: 297
    Use NAV5.0's "Microsoft Navision Mail.DLL" automation.

    Just use code to read from the HTML file and place the input data into the body of the e-mail as well as setting...
    [MnmdllVarName].HtmlFormatted := TRUE;
    
  • ReinhardReinhard Member Posts: 249
    Variables:
    objApp : Automation : 'Microsoft Outlook 11.0 Object Library'.Application
    objMail : Automation : 'Microsoft Outlook 11.0 Object Library'.MailItem

    //Create application 
    IF ISCLEAR(objApp) THEN CREATE(objApp); 
    
    //Create mail item 
    objMail := objApp.CreateItem(0);
    
    // set properties
    objMail."To"('someone@somewhere.com');
    objMail.Subject('Tienes correo');
    
    objMail.HTMLBody(' whatever html string you want to put here... ');
    
    //Uncomment for display email 
    //objMail.Display();
    
    //Send mail 
    objMail.Send();
    


    you have to have outlook to use this code.
    code shamelessly stolen from
    http://tricksnavision.blogspot.com/
  • libin80libin80 Member Posts: 24
    Hi Reinhard,

    This is a very simple way of sending the HTML contents using Outlook. I have been breaking my head for more than a week to solve this. Thanks for the solution. :)

    But, Still i face a problem. I have converted a report to html. I am trying to read the Html file and passing the Html code to
    'objMail.HTMLBody'. But, i have no way of adding more than 1024 characters as i am not able to use BigText or Array or Instream. I dont find any way of adding more Html lines.

    Is there any workaround for this? :-k

    Thanks
    Libin D
  • XypherXypher Member Posts: 297
    edited 2008-04-28
    For some reason my Microsoft Outlook 11.0 Object isn't registered so I am unable to attempt any tests at the time (nor do I have the time to get it to work.)

    Take a look at http://www.mibuso.com/forum/viewtopic.php?t=5496

    There is some example code with using a different automation. One that clearly shows the use of a function to append lines to the current body. (BSTRConverterBody in specific.)
  • pmusupmusu Member Posts: 55
    I have recently done something similar using SMTP OCX.
    It works with Outlook and Non-Outlook email clients as SMTP is a sort of standard.

    You can use HTML in the message like use tables, bold italic etc.

    The SMTP OCX is available from the download section in this forum.

    If you need anything else, I will try and help.
  • libin80libin80 Member Posts: 24
    Hi there,

    Thanks for the quick responses.

    I did change the body type to HTML & other stuffs. But still i cannot get it work.

    All my begin tag(ie. '<' ) and end tag (ie. '>') are converted to > and < notation when i use the 'AddBodyline() method.

    And I am not able to figure out a way to pass more than 1024 characters if i use Mailitem.HtmlBody

    Does anybody have an idea?

    Thanks & Regards,
    LIBIN D.
  • sankarganeshsankarganesh Member Posts: 9
    Is their any posibility to attach the file in outlook object library mail item.

    -sankar ganesh
  • XypherXypher Member Posts: 297
    IF ISCLEAR(MSOLOApp) THEN
      CREATE(MSOLOApp);
    
    MSOLOMailItem      := MSOLOApp.CreateItem(0);
    MSOLOAttachments   := MSOLOMailItem.Attachments;
    
    MSOLOMailItem."To" := 'email@emailaddress.com';
    
    MSOLOAttachments.Add('C:\Documents And Settings\sganesh\Desktop\test.txt');
    
    MSOLOMailItem.Send;
    

    Only problem is, you will get the Allow/Deny pop-up dialog every time you try to send an e-mail. (Unless there is a way to remove this, I'm not quite sure)
  • navuser1navuser1 Member Posts: 1,329
    Reinhard wrote:
    Variables:
    objApp : Automation : 'Microsoft Outlook 11.0 Object Library'.Application
    objMail : Automation : 'Microsoft Outlook 11.0 Object Library'.MailItem

    //Create application 
    IF ISCLEAR(objApp) THEN CREATE(objApp); 
    
    //Create mail item 
    objMail := objApp.CreateItem(0);
    
    // set properties
    objMail."To"('someone@somewhere.com');
    objMail.Subject('Tienes correo');
    
    objMail.HTMLBody(' whatever html string you want to put here... ');
    
    //Uncomment for display email 
    //objMail.Display();
    
    //Send mail 
    objMail.Send();
    


    you have to have outlook to use this code.
    code shamelessly stolen from
    http://tricksnavision.blogspot.com/


    I have used the same code but it does not send the HTML body into my Gmail account or other.

    My CODE in Nav


    // Automation Start
    //Create application
    IF ISCLEAR(objApp) THEN CREATE(objApp);

    //Create mail item
    objMail := objApp.CreateItem(0);

    // set properties
    objMail."To"('navuser1@gmail.com');
    objMail.Subject('Important');

    objMail.BodyFormat:=2;
    objMail.HTMLBody :='<a href='+Text101+'>navuser1</a>';

    //Uncomment for display email
    objMail.Display();

    //Send mail
    objMail.Send();


    // Automation End;

    Text101 :=CurrForm.URL;
    Now or Never
  • StLiStLi Member Posts: 83
    Hi,

    I need to mail an e-Mail with a HTML body two, but i also need to change the send address (the customer wants to send the mails from its "info@domain.com"-Address instead of the current usernames (like "john.doe@domain.com") i saw that the mail automation has a function called "sendusingaccount" but it requires an account object and i don't know how to set the account-object for this task.

    edit: [solved]

    i just found out i overlooked the function "SentOnBehalfOfName" which works just fine for me.

    regards
    stli
Sign In or Register to comment.