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.
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.
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.)
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();
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.
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.)
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.)
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)
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();
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.
Comments
Freelance Dynamics AX
Blog : http://axnmaia.wordpress.com/
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.
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=)
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
I don't use anything yet because I don't know what can I do this.
Thanks,
Angels
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...
objApp : Automation : 'Microsoft Outlook 11.0 Object Library'.Application
objMail : Automation : 'Microsoft Outlook 11.0 Object Library'.MailItem
you have to have outlook to use this code.
code shamelessly stolen from
http://tricksnavision.blogspot.com/
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
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.)
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.
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.
-sankar ganesh
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)
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;
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