Sending the content of an HTML in a mail
AitorEG
Member Posts: 342
Hi everyone,
I need to send the content of an URL into the body of an email. In the marketing setup window, I am using CU397
I've added an URL. I need to send the content located into that URL. Is this possible?
For example:
Of course this is not working, but, could be an approach? Or it's impossible to do this?
Thank you very much
I need to send the content of an URL into the body of an email. In the marketing setup window, I am using CU397
I've added an URL. I need to send the content located into that URL. Is this possible?
For example:
olMailItem.HTMLBody := '<a href="http://xxxxx.com/boletin/boletin.html"/a>'; //If we want to send in HTML format olMailItem.BodyFormat := 2; olMailItem.Display(ShowNewMailDialogOnSend); //If we want to display outlook dialog window olMailItem.Send;
Of course this is not working, but, could be an approach? Or it's impossible to do this?
Thank you very much
0
Best Answer
-
Thanks for your answer. I've solved this issue this way:
//descargamos el fichero HTMl de la URL lHttpWebRequest := lHttpWebRequest.Create(pURL); lHttpWebRequest.Method :='GET'; lHttpWebRequest.KeepAlive := TRUE; lHttpWebRequest.AllowAutoRedirect := TRUE; lHttpWebRequest.UseDefaultCredentials := TRUE; lHttpWebRequest.Timeout := 60000; lTempBLob.INIT; lTempBLob.Blob.CREATEINSTREAM(lResponseInStream); lWebRequestHelper.GetWebResponse(lHttpWebRequest,lHttpWebResponse,lResponseInStream,lHttpStatusCode,lResponseHeaders,GUIALLOWED); lTempBLob.INSERT; lTempBLob.CALCFIELDS(Blob); lFileMgt.BLOBExport(lTempBLob,'C:\Users\Public\Documents\boletin\boletin.html',TRUE); MyFile.OPEN('C:\Users\Public\Documents\boletin\boletin.html'); MyFile.CREATEINSTREAM(StreamInTest); WHILE NOT StreamInTest.EOS DO BEGIN StreamInTest.READTEXT(Buffer); WholeBody := WholeBody + Buffer; END; MyFile.CLOSE;
Variables:StreamInTest InStream Buffer Text lHttpWebRequest DotNet System.Net.HttpWebRequest.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' lTempBLob Record TempBlob lResponseInStream InStream lWebRequestHelper Codeunit Web Request Helper lHttpWebResponse DotNet System.Net.HttpWebResponse.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' lHttpStatusCode DotNet System.Net.HttpStatusCode.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' lResponseHeaders DotNet System.Collections.Specialized.NameValueCollection.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' lFileMgt Codeunit File Management
0
Answers
-
This will work fine, the only thing you need to do is to send the full HTML version of the email in olMailItem.HTMLBody.
e.g.
olMailItem.HTMLBody := '<!doctype html><html lang=en><head><meta charset=utf-8><title>blah</title></head><body><p>I'm the content</p><a href="http://xxxxx.com/boletin/boletin.html"/a></body></html>'
I hope this helps.1 -
Thanks for your answer. I've solved this issue this way:
//descargamos el fichero HTMl de la URL lHttpWebRequest := lHttpWebRequest.Create(pURL); lHttpWebRequest.Method :='GET'; lHttpWebRequest.KeepAlive := TRUE; lHttpWebRequest.AllowAutoRedirect := TRUE; lHttpWebRequest.UseDefaultCredentials := TRUE; lHttpWebRequest.Timeout := 60000; lTempBLob.INIT; lTempBLob.Blob.CREATEINSTREAM(lResponseInStream); lWebRequestHelper.GetWebResponse(lHttpWebRequest,lHttpWebResponse,lResponseInStream,lHttpStatusCode,lResponseHeaders,GUIALLOWED); lTempBLob.INSERT; lTempBLob.CALCFIELDS(Blob); lFileMgt.BLOBExport(lTempBLob,'C:\Users\Public\Documents\boletin\boletin.html',TRUE); MyFile.OPEN('C:\Users\Public\Documents\boletin\boletin.html'); MyFile.CREATEINSTREAM(StreamInTest); WHILE NOT StreamInTest.EOS DO BEGIN StreamInTest.READTEXT(Buffer); WholeBody := WholeBody + Buffer; END; MyFile.CLOSE;
Variables:StreamInTest InStream Buffer Text lHttpWebRequest DotNet System.Net.HttpWebRequest.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' lTempBLob Record TempBlob lResponseInStream InStream lWebRequestHelper Codeunit Web Request Helper lHttpWebResponse DotNet System.Net.HttpWebResponse.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' lHttpStatusCode DotNet System.Net.HttpStatusCode.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' lResponseHeaders DotNet System.Collections.Specialized.NameValueCollection.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' lFileMgt Codeunit File Management
0 -
Hi again,
I've just found another problem with this...
Is it possible to add to the body of the mail content that it's no in HTML, apparte from the already added HTML?
Thank you very much0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 322 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
