针对outlook制作html邮件样式问题

yangchun1213 2011-04-01 04:02:55
为什么我制作的html格式的邮件,在浏览器中预览很正常,但发送到outlook2007中时,有些位置有了偏移,而且td缩短了,怎样解决这样的问题啊,求大侠帮忙。
...全文
935 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangchun1213 2011-04-02
  • 打赏
  • 举报
回复

private string EmailBody(string sAccountNums)
{
try
{
ReportViewer RViewer = new ReportViewer();
RViewer.ServerReport.ReportServerUrl = new Uri(CRM.SystemLibrary.Global.ApplicationVar(oUserInfo.CountryCode, oUserInfo.LangCode, "ReportingServer"));
RViewer.ServerReport.ReportPath = "/SIS/" + oUserInfo.CountryCode + "/Payment_Reminder ";
RViewer.ProcessingMode = ProcessingMode.Remote;
RViewer.ServerReport.ReportServerCredentials = new CRM.UILayer._Initialize.CustomReportCredentials();

string JobsDBLogoURL = ConfigurationManager.AppSettings["JobsDBLogoURL"].ToString();

ReportParameter[] Parameters = new ReportParameter[6];
Parameters[0] = new ReportParameter("ReminderType", ReminderType().ToString());
Parameters[1] = new ReportParameter("AccountNums", sAccountNums);
Parameters[2] = new ReportParameter("ReminderDays", ReminderDays().ToString());
Parameters[3] = new ReportParameter("ReminderDate", Convert.ToDateTime(txtReminderDate.Text).ToString("MM/dd/yyyy"));
Parameters[4] = new ReportParameter("ReminderDateType", ddlReminderDate.SelectedIndex.ToString());
Parameters[5] = new ReportParameter("CountryCode", base.oUserInfo.CountryCode);

RViewer.ServerReport.SetParameters(Parameters);
RViewer.ServerReport.Refresh();

string format = "HTML4.0";
string devInfo = null;

Microsoft.Reporting.WebForms.Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension = "htm";

byte[] result = null;
result = RViewer.ServerReport.Render(format, devInfo, out mimeType, out encoding, out extension, out streamids, out warnings);


MemoryStream ms = new MemoryStream(result); ;
StreamReader sr = new StreamReader(ms);
string line = sr.ReadToEnd();

//0022177: SIS 3.0 - Invoice Payment Reminder - UI style issue in the Email
//line变量中有多个<img />标签,只需把第一个<img />标签替换成logo图片,而其他<img />标签不用替换
int i = 0;
line = Regex.Replace(line, @"(?is)<img[^>]*?>", delegate(Match m)
{
i++;
if (i == 1)
return "<img alt='JobsDB.com' src='" + JobsDBLogoURL + "'/>";
else
return "";
});

//line = Regex.Replace(line, "<img[^>]*>", @"<img alt='JobsDB.com' src='" + JobsDBLogoURL + "'>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
return line;
}
catch (Exception ex)
{
ExceptionManager.Handle(Page, ex, "Invoice Payment - EmailBody()");
}
return string.Empty;
}

我上面那个方法是生成html邮件的的<body></body>部分的,
主要是通过line变量生成的,line变量是去读取一个报表服务器生成的,这怎么定义样式啊?
cfvgodot 2011-04-01
  • 打赏
  • 举报
回复
[Quote=引用楼主 yangchun1213 的回复:]
为什么我制作的html格式的邮件,在浏览器中预览很正常,但发送到outlook2007中时,有些位置有了偏移,而且td缩短了,怎样解决这样的问题啊,求大侠帮忙。
[/Quote]

CSS定义好。。。
子夜__ 2011-04-01
  • 打赏
  • 举报
回复
HTML生成图片在发

using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using mshtml;
using SHDocVw;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
try
{
webBrowser1.Navigate("http://www.google.com/");
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}

mshtml.IHTMLDocument2 doc = webBrowser1.Document.DomDocument as IHTMLDocument2;
IHTMLElementRender render = doc.body as IHTMLElementRender;

using (System.Drawing.Bitmap img = new Bitmap(webBrowser1.Width, webBrowser1.Height))
using (Graphics g = Graphics.FromImage(img))
{
IntPtr hdc = g.GetHdc();
render.DrawToDC(hdc);
g.ReleaseHdc(hdc);
img.Save("c:\\temp\\a.jpg");
}
}
catch (Exception err)
{
MessageBox.Show(err.ToString());
}
}
}

/// <remarks>
/// prototype from Tlbimp
/// </remarks>
[
Guid("3050F669-98B5-11CF-BB82-00AA00BDCE0B"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown),
ComImport
]
interface IHTMLElementRender
{
void DrawToDC([In] IntPtr hDC);
void SetDocumentPrinter([In, MarshalAs(UnmanagedType.BStr)] string bstrPrinterName, [In] IntPtr hDC);
};
}


html生成图片

62,050

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧