Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i don't understand how to show data url images in outlook using c#.net

my code is

in code behind :
C#
Outlook.Application outlookApp = new Outlook.Application();
Outlook._MailItem mailItem = (Outlook._MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
mailItem.To = TomailIds;
mailItem.HTMLBody = FileContents;
mailItem.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;
// body, bcc etc...

mailItem.Display(true);

FileContents variable has following data

XML
<html><head></STYLE><STYLE type=text/css>.Advanceap{background-color:Transparent;border:1pt none Black;}.Advancea17xB{border:1pt none Black;background-color:Transparent;}.Advancea15{border:1pt none Black;background-color:White;}.Advancer1{HEIGHT:100%;WIDTH:100%}.Advancer2{HEIGHT:100%;WIDTH:100%;overflow:hidden}.Advancer3{HEIGHT:100%}.Advancer4{border-style:none}.Advancer5{border-left-style:none}.Advancer6{border-right-style:none}.Advancer7{border-top-style:none}.Advancer8{border-bottom-style:none}.Advancer10{border-collapse:collapse}.Advancer9{border-collapse:collapse;table-layout:fixed}.Advancer11{WIDTH:100%;overflow-x:hidden}.Advancer12{position:absolute;display:none;background-color:white;border:1px solid black;}.Advancer13{text-decoration:none;color:black;cursor:pointer;}.Advancer14{font-size:0pt}.Advancer15{direction:RTL;unicode-bidi:embed}.Advancer16{margin-top:0pt;margin-bottom:0pt}.Advancer17{HEIGHT:100%;WIDTH:100%;display:inline-table}.Advancer18{HEIGHT:100%;display:inline-table} * { box-sizing: border-box }</STYLE></head><body>
<META content=text/css http-equiv=Content-Style-Type>
<META content=text/javascript http-equiv=Content-Script-Type>
<META content=http://localhost/ReportServer?xx http-equiv=Location>
<META content=http://localhost/ReportServer?xxx http-equiv=Uri>
<META content="03/04/2013 14:20:36" http-equiv=Last-Modified>
<META name=Area content=AREA1>
<META name=Branch content=All>
<META name=period content="last Year">
<META name=StartDate content=Null>
<META name=EndDate content=Null>
<META name=Generator content="Microsoft Report 8.0 ">
<META name=Originator content="Microsoft Report 8.0 ">


<DIV style="WIDTH: 100%; DIRECTION: ltr; HEIGHT: 100%" dir=ltr id=oReportDiv>
<DIV style="WIDTH: 100%; HEIGHT: 100%" class=Advanceap>
<TABLE cellSpacing=0 cellPadding=0>
<TBODY>
<TR>
<TD id=oReportCell>
<DIV class=Advancea17xB growRect="true">
<TABLE lang=en-US class=Advancer10 border=0 cellSpacing=0 cellPadding=0 cols=1>
<TBODY>
<TR vAlign=top>
<TD style="MIN-WIDTH: 139.17mm; WIDTH: 139.17mm; HEIGHT: 82.25mm">
<DIV><IMG onerror=this.errored=true; class=Advancea15 border=0 src="data:image/jpeg;base64,iVBORw0KGgoAAAAN8e333/w0M7fyjSjpCyBoQ00GG1aP/pELtaFg7OYRNjApprWEWlHL6ZV0qPkzYE6iaAcAj0z5WFgx+6AOHw+R/KwVK/DNEdVTjE2xYFsloe6voK9suIlVGMYkx80hB9eqCssQh+4Ii9gxJjxqYmIYctHsOyIcRMasqrjAe0ARIZCXAMIhL29ygwAEIAABCDRNAOHQtPswHgIQgAAEIJCXAMIhL29ygwAEIAABCDRNAOHQtPswHgIQgAAEIJCXAMIhL29ygwAEIAABCDRNAOHQtPswHgIQgAAEIJCXAMIhL29ygwAEIAABCDRNAOHQtPswHgIQgAAEIJCXAMIhL29ygwAEIAABCDRNAOHQtPswHgIQgAAEIJCXAMIhL29ygwAEIAABCDRNAOHQtPswHgIQgAAEIJCXAMIhL29ygwAEIAABCDRNAOHQtPswHgIQgAAEIJCXAMIhL29ygwAEIAABCDRNAOHQtPswHgIQgAAEIJCXwP8DV3xidnzNQu4AAAAASUVORK5CYII=alt=''"></DIV></TD></TR>
<TR>
<TD></TD></TR></TBODY></TABLE></DIV></TD>
<TD width="100%"></TD></TR>
<TR>
<TD height="100%"></TD></TR></TBODY></TABLE></DIV></DIV>
</body></html>


please help me
thanks in advance
Posted
v4
Comments
Please correct the code you posted.
This is not clearly visible.
Fred Flams 4-Mar-13 11:55am    
Hello, personnaly I would set the BodyFormat property before the Content property:

mailItem.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;
mailItem.HTMLBody = FileContents;

doing it in this order makes sure that the mail object is set to receive an HTML body, I'm not sure if it strips the HTML content if the Format is set to text.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900