We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problems getting HTML emails in PDF

Hi,

I am having an issue placing HTML emails which come from Outlook into a PDF. It works with simple messages, but on placing more complex ones I either get most of the message that does not appear on the PDF, or a NotSupportedException thrown on the pdf.Save method call. I took a look at this link (http://www.aspose.com/documentation/.net-components/aspose.pdf-for-.net/html-tags-in-text.html) so it may be that when Outlook messages (which are created by MS Word) have HTML tags which may not be supported by Aspose.Pdf.Generator. In that case, would it be recommended to create a Word Document with these Outlook HTML email messages and append it to my PDF via this method (<A href="https://forum.aspose.com/t/74694</A>)? Can someone from Aspose support get back to me on this? I will be happy to send over the HTML and any other files you might need.</P> <P>Thanks,</P> <P>Herman</P> <P> </P> <P> </P> <P>Code that reads HTML and saves:</P><FONT size=2 face=Consolas><FONT size=2 face=Consolas> <P></FONT></FONT><FONT color=#2b91af size=2 face=Consolas><FONT color=#2b91af size=2 face=Consolas><FONT color=#2b91af size=2 face=Consolas>Section</FONT></FONT></FONT><FONT size=2 face=Consolas><FONT size=2 face=Consolas> secBody = pdf.Sections.Add();</P> <P></FONT></FONT><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas><FONT color=#0000ff size=2 face=Consolas>using</FONT></FONT></FONT><FONT size=2 face=Consolas><FONT size=2 face=Consolas> (</FONT></FONT><FONT color=#2b91af size=2 face=Consolas><FONT color=#2b91af size=2 face=Consolas><FONT color=#2b91af size=2 face=Consolas>StreamReader</FONT></FONT></FONT><FONT size=2 face=Consolas><FONT size=2 face=Consolas> sr = </FONT></FONT><FONT color=#2b91af size=2 face=Consolas><FONT color=#2b91af size=2 face=Consolas><FONT color=#2b91af size=2 face=Consolas>File</FONT></FONT></FONT><FONT size=2 face=Consolas><FONT size=2 face=Consolas>.OpenText(</FONT></FONT><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas><FONT color=#a31515 size=2 face=Consolas>@"F:\emailtest1.html"))

{

Text txt = new Text(secBody, sr.ReadToEnd());

txt.IsHtmlTagSupported = true;

secBody.Paragraphs.Add(txt);

}

pdf.Save("C:\\temp\\test.pdf");

NotSupportException details, this only occurs on some email HTML files:

System.NotSupportedException was unhandled
Message=The given path's format is not supported.
Source=mscorlib
StackTrace:
at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)
at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath)
at System.IO.Path.GetFullPath(String path)
at .š.( , Image )
at .š.( )
at ..( )
at ..( )
at ..( )
at ..( )
at ..( )
at .š.( )
at .‡.(String )
at “.e.(Pdf , Section , Cell , Text , HeaderFooter , , )
at “.e.(Pdf , Section , Table , Cell , Text , HeaderFooter , , )
at “..(Pdf , Section , HeaderFooter , Table , Row , Cell , Text , , , Boolean )
at “..(Pdf , Section , )
at ’.Š.(Pdf )
at ’.’.( , Pdf )
at Aspose.Pdf.Generator.Pdf.Save(String pdfFile)
at AsposeTestApp.Program.Main(String[] args) in C:\VSHome\VS2010\Projects\AsposeTestApp\AsposeTestApp\Program.cs:line 75
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Hi Herman,

Thanks for your interest in our products.

Kindly share template HTML file with us. This will help us to figure out the issue and reply back to you soon.

We apologize for your inconvenience.

Thanks & Regards,

Hi Rashid,

I checked with my firm and I the HTML contains confidential information so I can't circulate it outside of the company. I discovered I can get the Aspose.Words classes to parse the HTML fine, let me try that...

Hi Herman,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

As your template file has some confidential data, so you may make this thread as private by checking "Keep this post as private" checkbox at the bottom when replying to the post, this way only Aspose staff and you would be able to see your attachments. Alternately, you may check this link on how to send the file via email. This will help us reproduce your issue at our end for resolution.

Thank You & Best Regards,